File tree 1 file changed +20
-4
lines changed
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -498,12 +498,28 @@ unsafe impl<T: Send + ?Sized> Send for Unique<T> { }
498
498
#[ unstable( feature = "unique" , issue = "27730" ) ]
499
499
unsafe impl < T : Sync + ?Sized > Sync for Unique < T > { }
500
500
501
+ #[ cfg( stage0) ]
502
+ macro_rules! unique_new {
503
+ ( ) => (
504
+ /// Creates a new `Unique`.
505
+ pub unsafe fn new( ptr: * mut T ) -> Unique <T > {
506
+ Unique { pointer: NonZero :: new( ptr) , _marker: PhantomData }
507
+ }
508
+ )
509
+ }
510
+ #[ cfg( not( stage0) ) ]
511
+ macro_rules! unique_new {
512
+ ( ) => (
513
+ /// Creates a new `Unique`.
514
+ pub unsafe const fn new( ptr: * mut T ) -> Unique <T > {
515
+ Unique { pointer: NonZero :: new( ptr) , _marker: PhantomData }
516
+ }
517
+ )
518
+ }
519
+
501
520
#[ unstable( feature = "unique" , issue = "27730" ) ]
502
521
impl < T : ?Sized > Unique < T > {
503
- /// Creates a new `Unique`.
504
- pub unsafe fn new ( ptr : * mut T ) -> Unique < T > {
505
- Unique { pointer : NonZero :: new ( ptr) , _marker : PhantomData }
506
- }
522
+ unique_new ! { }
507
523
508
524
/// Dereferences the content.
509
525
pub unsafe fn get ( & self ) -> & T {
You can’t perform that action at this time.
0 commit comments