File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change 124124#![ feature( const_option) ]
125125#![ feature( const_pin) ]
126126#![ feature( const_replace) ]
127+ #![ feature( const_ptr_is_null) ]
127128#![ feature( const_ptr_offset) ]
128129#![ feature( const_ptr_offset_from) ]
129130#![ feature( const_ptr_read) ]
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ impl<T: ?Sized> Unique<T> {
9292
9393 /// Creates a new `Unique` if `ptr` is non-null.
9494 #[ inline]
95- pub fn new ( ptr : * mut T ) -> Option < Self > {
95+ pub const fn new ( ptr : * mut T ) -> Option < Self > {
9696 if !ptr. is_null ( ) {
9797 // SAFETY: The pointer has already been checked and is not null.
9898 Some ( unsafe { Unique { pointer : ptr as _ , _marker : PhantomData } } )
@@ -115,7 +115,7 @@ impl<T: ?Sized> Unique<T> {
115115 /// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
116116 #[ must_use]
117117 #[ inline]
118- pub unsafe fn as_ref ( & self ) -> & T {
118+ pub const unsafe fn as_ref ( & self ) -> & T {
119119 // SAFETY: the caller must guarantee that `self` meets all the
120120 // requirements for a reference.
121121 unsafe { & * self . as_ptr ( ) }
@@ -128,7 +128,7 @@ impl<T: ?Sized> Unique<T> {
128128 /// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
129129 #[ must_use]
130130 #[ inline]
131- pub unsafe fn as_mut ( & mut self ) -> & mut T {
131+ pub const unsafe fn as_mut ( & mut self ) -> & mut T {
132132 // SAFETY: the caller must guarantee that `self` meets all the
133133 // requirements for a mutable reference.
134134 unsafe { & mut * self . as_ptr ( ) }
You can’t perform that action at this time.
0 commit comments