File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -109,21 +109,33 @@ impl<'a> NodeTable<'a> {
109109 }
110110
111111 /// Mutable access to node flags.
112+ ///
113+ /// # Note
114+ ///
115+ /// Internally, we rely on a conversion of u64 to usize.
116+ /// This conversion is fallible on some platforms.
117+ /// If the conversion fails, an empty slice is returned.
112118 pub fn flags_array_mut ( & mut self ) -> & mut [ NodeFlags ] {
113119 unsafe {
114120 std:: slice:: from_raw_parts_mut (
115121 self . table_ . flags . cast :: < NodeFlags > ( ) ,
116- usize:: try_from ( self . table_ . num_rows ) . unwrap ( ) ,
122+ usize:: try_from ( self . table_ . num_rows ) . unwrap_or ( 0 ) ,
117123 )
118124 }
119125 }
120126
121127 /// Mutable access to node times.
128+ ///
129+ /// # Note
130+ ///
131+ /// Internally, we rely on a conversion of u64 to usize.
132+ /// This conversion is fallible on some platforms.
133+ /// If the conversion fails, an empty slice is returned.
122134 pub fn time_array_mut ( & mut self ) -> & mut [ Time ] {
123135 unsafe {
124136 std:: slice:: from_raw_parts_mut (
125137 self . table_ . time . cast :: < Time > ( ) ,
126- usize:: try_from ( self . table_ . num_rows ) . unwrap ( ) ,
138+ usize:: try_from ( self . table_ . num_rows ) . unwrap_or ( 0 ) ,
127139 )
128140 }
129141 }
You can’t perform that action at this time.
0 commit comments