File tree 2 files changed +4
-3
lines changed
2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change 124
124
#![ feature( const_option) ]
125
125
#![ feature( const_pin) ]
126
126
#![ feature( const_replace) ]
127
+ #![ feature( const_ptr_is_null) ]
127
128
#![ feature( const_ptr_offset) ]
128
129
#![ feature( const_ptr_offset_from) ]
129
130
#![ feature( const_ptr_read) ]
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ impl<T: ?Sized> Unique<T> {
92
92
93
93
/// Creates a new `Unique` if `ptr` is non-null.
94
94
#[ inline]
95
- pub fn new ( ptr : * mut T ) -> Option < Self > {
95
+ pub const fn new ( ptr : * mut T ) -> Option < Self > {
96
96
if !ptr. is_null ( ) {
97
97
// SAFETY: The pointer has already been checked and is not null.
98
98
Some ( unsafe { Unique { pointer : ptr as _ , _marker : PhantomData } } )
@@ -115,7 +115,7 @@ impl<T: ?Sized> Unique<T> {
115
115
/// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
116
116
#[ must_use]
117
117
#[ inline]
118
- pub unsafe fn as_ref ( & self ) -> & T {
118
+ pub const unsafe fn as_ref ( & self ) -> & T {
119
119
// SAFETY: the caller must guarantee that `self` meets all the
120
120
// requirements for a reference.
121
121
unsafe { & * self . as_ptr ( ) }
@@ -128,7 +128,7 @@ impl<T: ?Sized> Unique<T> {
128
128
/// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
129
129
#[ must_use]
130
130
#[ inline]
131
- pub unsafe fn as_mut ( & mut self ) -> & mut T {
131
+ pub const unsafe fn as_mut ( & mut self ) -> & mut T {
132
132
// SAFETY: the caller must guarantee that `self` meets all the
133
133
// requirements for a mutable reference.
134
134
unsafe { & mut * self . as_ptr ( ) }
You can’t perform that action at this time.
0 commit comments