@@ -347,17 +347,16 @@ impl<T:?Sized> MarkerTrait for T { }
347
347
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
348
348
pub trait PhantomFn < A : ?Sized , R : ?Sized =( ) > { }
349
349
350
- /// `PhantomData` is a way to tell the compiler about fake fields.
351
- /// Phantom data is required whenever type parameters are not used.
352
- /// The idea is that if the compiler encounters a `PhantomData<T>`
353
- /// instance, it will behave *as if* an instance of the type `T` were
354
- /// present for the purpose of various automatic analyses.
350
+ /// `PhantomData<T>` allows you to describe that a type acts as if it stores a value of type `T`,
351
+ /// even though it does not. This allows you to inform the compiler about certain safety properties
352
+ /// of your code.
353
+ ///
354
+ /// Though they both have scary names, `PhantomData<T>` and "phantom types" are unrelated. 👻👻👻
355
355
///
356
356
/// # Examples
357
357
///
358
358
/// When handling external resources over a foreign function interface, `PhantomData<T>` can
359
- /// prevent mismatches by enforcing types in the method implementations, although the struct
360
- /// doesn't actually contain values of the resource type.
359
+ /// prevent mismatches by enforcing types in the method implementations:
361
360
///
362
361
/// ```
363
362
/// # trait ResType { fn foo(&self); };
@@ -398,11 +397,6 @@ pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
398
397
/// commonly necessary if the structure is using an unsafe pointer
399
398
/// like `*mut T` whose referent may be dropped when the type is
400
399
/// dropped, as a `*mut T` is otherwise not treated as owned.
401
- ///
402
- /// FIXME. Better documentation and examples of common patterns needed
403
- /// here! For now, please see [RFC 738][738] for more information.
404
- ///
405
- /// [738]: https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md
406
400
#[ lang="phantom_data" ]
407
401
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
408
402
pub struct PhantomData < T : ?Sized > ;
0 commit comments