5
5
6
6
// TODO: Potentially add some serialization scheme?
7
7
8
- use alloc:: { vec, vec :: Vec } ;
9
- use hashbrown :: HashSet ;
8
+ use alloc:: vec:: Vec ;
9
+ use indexmap :: IndexSet ;
10
10
11
11
use crate :: ZoneInfoTransitionData ;
12
12
@@ -22,7 +22,11 @@ pub struct TzifBlockV2 {
22
22
23
23
impl TzifBlockV2 {
24
24
pub fn from_transition_data ( data : & ZoneInfoTransitionData ) -> Self {
25
- let mut local_time_set = HashSet :: new ( ) ;
25
+ let mut local_time_set = IndexSet :: new ( ) ;
26
+ local_time_set. insert ( LocalTimeRecord {
27
+ offset : data. lmt . offset ,
28
+ is_dst : data. lmt . saving . as_secs ( ) != 0 ,
29
+ } ) ;
26
30
let mut transition_times = Vec :: default ( ) ;
27
31
let mut transition_types = Vec :: default ( ) ;
28
32
for transition in & data. transitions {
@@ -39,19 +43,10 @@ impl TzifBlockV2 {
39
43
}
40
44
}
41
45
42
- let first = LocalTimeRecord {
43
- offset : data. lmt . offset ,
44
- is_dst : data. lmt . saving . as_secs ( ) != 0 ,
45
- } ;
46
-
47
- let mut local_time_types: Vec < LocalTimeRecord > = vec ! [ first] ;
48
- local_time_types. extend_from_slice (
49
- local_time_set
50
- . iter ( )
51
- . cloned ( )
52
- . collect :: < Vec < LocalTimeRecord > > ( )
53
- . as_slice ( ) ,
54
- ) ;
46
+ let local_time_types = local_time_set
47
+ . iter ( )
48
+ . cloned ( )
49
+ . collect :: < Vec < LocalTimeRecord > > ( ) ;
55
50
56
51
Self {
57
52
transition_times,
0 commit comments