@@ -7,47 +7,38 @@ use alloc::string::String;
77use core:: mem:: { align_of, size_of} ;
88use static_assertions:: { assert_cfg, assert_eq_size, const_assert, const_assert_eq} ;
99
10- /// A compact string representation equal to [`String`][String] in size with guaranteed inlining.
10+ /// A compact string representation equal to [`String`] in size with guaranteed inlining.
1111///
1212/// This representation relies on pointer alignment to be able to store a discriminant bit in its
13- /// inline form that will never be present in its [`String`][String] form, thus
13+ /// inline form that will never be present in its [`String`] form, thus
1414/// giving us 24 bytes on 64-bit architectures, and 12 bytes on 32-bit, minus one bit, to encode our
1515/// inline string. It uses the rest of the discriminant bit's byte to encode the string length, and
1616/// the remaining bytes (23 or 11 depending on arch) to store the string data. When the available space is exceeded,
17- /// it swaps itself out with a [`String`][String] containing its previous
18- /// contents, relying on the discriminant bit in the [`String`][String] 's pointer to be unset, so we can
19- /// store the [`String`][String] safely without taking up any extra space for a discriminant.
17+ /// it swaps itself out with a [`String`] containing its previous
18+ /// contents, relying on the discriminant bit in the [`String`]'s pointer to be unset, so we can
19+ /// store the [`String`] safely without taking up any extra space for a discriminant.
2020///
21- /// This performs generally as well as [`String`][String] on all ops on boxed strings, and
22- /// better than [`String`][String]s on inlined strings.
23- ///
24- /// [String]: https://doc.rust-lang.org/std/string/struct.String.html
21+ /// This performs generally as well as [`String`] on all ops on boxed strings, and
22+ /// better than [`String`]s on inlined strings.
2523#[ derive( Debug ) ]
2624pub struct Compact ;
2725
28- /// A representation similar to [`Compact`][Compact] but which doesn't re-inline strings.
26+ /// A representation similar to [`Compact`] but which doesn't re-inline strings.
2927///
30- /// This is a variant of [`Compact`][Compact] which doesn't aggressively inline strings.
31- /// Where [`Compact`][Compact] automatically turns a heap allocated string back into an
32- /// inlined string if it should become short enough, [`LazyCompact`][LazyCompact] keeps
28+ /// This is a variant of [`Compact`] which doesn't aggressively inline strings.
29+ /// Where [`Compact`] automatically turns a heap allocated string back into an
30+ /// inlined string if it should become short enough, [`LazyCompact`] keeps
3331/// it heap allocated once heap allocation has occurred. If your aim is to defer heap
3432/// allocation as much as possible, rather than to ensure cache locality, this is the
3533/// variant you want - it won't allocate until the inline capacity is exceeded, and it
3634/// also won't deallocate once allocation has occurred, which risks reallocation if the
3735/// string exceeds its inline capacity in the future.
38- ///
39- /// [Compact]: struct.Compact.html
40- /// [String]: https://doc.rust-lang.org/std/string/struct.String.html
4136#[ derive( Debug ) ]
4237pub struct LazyCompact ;
4338
44- /// Marker trait for [`SmartString`][SmartString] representations.
45- ///
46- /// See [`LazyCompact`][LazyCompact] and [`Compact`][Compact].
39+ /// Marker trait for [`SmartString`] representations.
4740///
48- /// [SmartString]: struct.SmartString.html
49- /// [Compact]: struct.Compact.html
50- /// [LazyCompact]: struct.LazyCompact.html
41+ /// See [`LazyCompact`] and [`Compact`].
5142pub trait SmartStringMode {
5243 /// The boxed string type for this layout.
5344 type BoxedString : BoxedString + From < String > ;
0 commit comments