File tree Expand file tree Collapse file tree 4 files changed +0
-60
lines changed Expand file tree Collapse file tree 4 files changed +0
-60
lines changed Original file line number Diff line number Diff line change @@ -112,26 +112,6 @@ impl<T> OnceCell<T> {
112112 }
113113 }
114114
115- /// Get a mutable reference to the underlying value, without checking if the cell
116- /// is initialized.
117- ///
118- /// # Safety
119- ///
120- /// Caller must ensure that the cell is in initialized state, and that
121- /// the contents are acquired by (synchronized to) this thread.
122- pub ( crate ) unsafe fn get_mut_unchecked ( & mut self ) -> & mut T {
123- debug_assert ! ( self . is_initialized( ) ) ;
124- let slot: & mut Option < T > = & mut * self . value . get ( ) ;
125- match slot {
126- Some ( value) => value,
127- // This unsafe does improve performance, see `examples/bench`.
128- None => {
129- debug_assert ! ( false ) ;
130- hint:: unreachable_unchecked ( )
131- }
132- }
133- }
134-
135115 /// Gets the mutable reference to the underlying value.
136116 /// Returns `None` if the cell is empty.
137117 pub ( crate ) fn get_mut ( & mut self ) -> Option < & mut T > {
Original file line number Diff line number Diff line change @@ -122,26 +122,6 @@ impl<T> OnceCell<T> {
122122 }
123123 }
124124
125- /// Get a mutable reference to the underlying value, without checking if the cell
126- /// is initialized.
127- ///
128- /// # Safety
129- ///
130- /// Caller must ensure that the cell is in initialized state, and that
131- /// the contents are acquired by (synchronized to) this thread.
132- pub ( crate ) unsafe fn get_mut_unchecked ( & mut self ) -> & mut T {
133- debug_assert ! ( self . is_initialized( ) ) ;
134- let slot: & mut Option < T > = & mut * self . value . get ( ) ;
135- match slot {
136- Some ( value) => value,
137- // This unsafe does improve performance, see `examples/bench`.
138- None => {
139- debug_assert ! ( false ) ;
140- unreachable_unchecked ( )
141- }
142- }
143- }
144-
145125 /// Gets the mutable reference to the underlying value.
146126 /// Returns `None` if the cell is empty.
147127 pub ( crate ) fn get_mut ( & mut self ) -> Option < & mut T > {
Original file line number Diff line number Diff line change @@ -1095,17 +1095,6 @@ pub mod sync {
10951095 self . 0 . get_unchecked ( )
10961096 }
10971097
1098- /// Get a mutable reference to the underlying value, without checking if the
1099- /// cell is initialized.
1100- ///
1101- /// # Safety
1102- ///
1103- /// Caller must ensure that the cell is in initialized state, and that
1104- /// the contents are acquired by (synchronized to) this thread.
1105- pub unsafe fn get_mut_unchecked ( & mut self ) -> & mut T {
1106- self . 0 . get_mut_unchecked ( )
1107- }
1108-
11091098 /// Sets the contents of this cell to `value`.
11101099 ///
11111100 /// Returns `Ok(())` if the cell was empty and `Err(value)` if it was
Original file line number Diff line number Diff line change @@ -305,15 +305,6 @@ mod sync {
305305 }
306306 }
307307
308- #[ test]
309- fn once_cell_get_mut_unchecked ( ) {
310- let mut c = OnceCell :: new ( ) ;
311- c. set ( 92 ) . unwrap ( ) ;
312- unsafe {
313- assert_eq ! ( c. get_mut_unchecked( ) , & mut 92 ) ;
314- }
315- }
316-
317308 #[ test]
318309 fn once_cell_drop ( ) {
319310 static DROP_CNT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
You can’t perform that action at this time.
0 commit comments