@@ -603,8 +603,10 @@ unsafe impl<T: ?Sized> Freeze for *mut T {}
603603unsafe impl < ' a , T : ?Sized > Freeze for & ' a T { }
604604unsafe impl < ' a , T : ?Sized > Freeze for & ' a mut T { }
605605
606- /// A trait that indicates that it is safe to move an object of a type implementing it.
607- /// Since that is true for most types, it is automatically implemented in most cases.
606+ /// Types that are safe to move.
607+ ///
608+ /// Since moving objects is almost always safe, it is automatically implemented in most cases.
609+ ///
608610/// This trait is mainly used to build self referencial structs,
609611/// since moving an object with pointers to itself will invalidate them,
610612/// causing undefined behavior.
@@ -643,7 +645,7 @@ unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {}
643645/// [`Deref`]: ../ops/trait.Deref.html
644646/// [`swap`]: ../mem/fn.swap.html
645647///
646- /// # example
648+ /// # Examples
647649///
648650/// ```rust
649651/// #![feature(pin)]
@@ -652,21 +654,21 @@ unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {}
652654/// use std::marker::Pinned;
653655/// use std::ptr::NonNull;
654656///
655- /// // this is a self referencial struct since the slice field points to the data field.
656- /// // we cannot inform the compiler about that with a normal reference,
657+ /// // This is a self referencial struct since the slice field points to the data field.
658+ /// // We cannot inform the compiler about that with a normal reference,
657659/// // since this pattern cannot be described with the usual borrowing rules.
658- /// // instead we use a raw pointer, though one which is known to not be null,
659- /// // since we know its pointing at the string.
660+ /// // Instead we use a raw pointer, though one which is known to not be null,
661+ /// // since we know it's pointing at the string.
660662/// struct Unmovable {
661663/// data: String,
662664/// slice: NonNull<String>,
663665/// _pin: Pinned,
664666/// }
665667///
666668/// impl Unmovable {
667- /// // to ensure the data doesn't move when the function returns,
669+ /// // To ensure the data doesn't move when the function returns,
668670/// // we place it in the heap where it will stay for the lifetime of the object,
669- /// // and the only way to access it would be through a pointer to it
671+ /// // and the only way to access it would be through a pointer to it.
670672/// fn new(data: String) -> PinBox<Self> {
671673/// let res = Unmovable {
672674/// data,
@@ -685,13 +687,13 @@ unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {}
685687/// }
686688///
687689/// let unmoved = Unmovable::new("hello".to_string());
688- /// // the pointer should point to the correct location,
690+ /// // The pointer should point to the correct location,
689691/// // so long as the struct hasn't moved.
690- /// // meanwhile , we are free to move the pointer around
692+ /// // Meanwhile , we are free to move the pointer around.
691693/// let mut still_unmoved = unmoved;
692694/// assert_eq!(still_unmoved.slice, NonNull::from(&still_unmoved.data));
693695///
694- /// // now the only way to access to data (safely) is immutably,
696+ /// // Now the only way to access to data (safely) is immutably,
695697/// // so this will fail to compile:
696698/// // still_unmoved.data.push_str(" world");
697699///
0 commit comments