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