pub struct PackedPatterns<'data> {
    pub header: u32,
    pub elements: VarZeroVec<'data, PluralElementsPackedULE<ZeroSlice<PatternItem>>>,
}Expand description
๐ This item has a stack size of 32 bytes on the stable toolchain at release date.
ยงVariants
This supports a set of โstandardโ patterns plus up to two โvariantsโ. The variants are currently used by year formatting:
- Standard: Year, which could be partial precision (2-digit Gregorian)
 - Variant 0: Full Year, which is always full precision
 - Variant 1: Year With Era
 
And by time formatting:
- Standard: Hour only
 - Variant 0: Hour and minute
 - Variant 1: Hour, minute, and second
 
Variants should be used when the pattern could depend on the value being
formatted. For example, with YearStyle::Auto, any of these three
patterns could be selected based on the year value.
ยงRepresentation
Currently, there are at most 9 patterns that need to be stored together, named according to this table:
| Standard | Variant 0 | Variant 1 | |
|---|---|---|---|
| Long | La | Lb | Lc | 
| Medium | Ma | Mb | Mc | 
| Short | Sa | Sb | Sc | 
The header byte encodes which pattern in the patterns array corresponds to a particular cell in the table. It contains the following information:
- Bits 0-1: โLMSโ value of the standard column
 - Bit 2: โQโ value: 1 for directly-indexed variants; 0 for per-cell offsets
 - Bits 3-20: Packed offset into patterns table for each variant cell
 - Bits 21-31: unused/reserved
 
The LMS value determines which pattern index is used for the first column:
| LMS Value | Long Index | Medium Index | Short Index | 
|---|---|---|---|
| 0 (L=M=S) | 0 | 0 | 0 | 
| 1 (L, M=S) | 0 | 1 | 1 | 
| 2 (L=M, S) | 0 | 0 | 1 | 
| 3 (L, M, S) | 0 | 1 | 2 | 
If bit 2 is 1 (Q=1), it means there is one pattern per table cell,
with the index offset by the short index S from the table above.
However, this requires storing multiple, possibly duplicate, patterns in
the packed structure. The more common case is Q=0 and then to store
per-cell offsets in chunks of 3 bits per cell:
- Chunk = 0: Inherit according to the table below
 - Chunk = 1-7: Use pattern index Chunk - 1
 
This is summarized below:
| Cell in Table | Q=1 Pattern Index | Q=0 Header Bits | Inheritance | 
|---|---|---|---|
| Lb | S + 1 | 3-5 | La | 
| Mb | S + 2 | 6-8 | Ma | 
| Sb | S + 3 | 9-11 | Sa | 
| Lc | S + 4 | 12-14 | La | 
| Mc | S + 5 | 15-17 | Ma | 
| Sc | S + 6 | 18-20 | Sa | 
As a result, if there are no variants, bits 2 and higher will be all zero, making the header int suitable for varint packing, such as that used by postcard and other size-optimized serialization formats.
Fieldsยง
ยงheader: u32An encoding of which standard/variant cell corresponds to which entry in the patterns table. See class docs.
elements: VarZeroVec<'data, PluralElementsPackedULE<ZeroSlice<PatternItem>>>The list of patterns. Length should be between 1 and 9, depending on the header.
Implementationsยง
Sourceยงimpl PackedPatterns<'_>
 
impl PackedPatterns<'_>
Sourcepub fn to_builder(&self) -> PackedPatternsBuilder<'_>
 
pub fn to_builder(&self) -> PackedPatternsBuilder<'_>
Converts this packed data to a builder that can be mutated.
Trait Implementationsยง
Sourceยงimpl<'data> Clone for PackedPatterns<'data>
 
impl<'data> Clone for PackedPatterns<'data>
Sourceยงfn clone(&self) -> PackedPatterns<'data>
 
fn clone(&self) -> PackedPatterns<'data>
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl<'data> Debug for PackedPatterns<'data>
 
impl<'data> Debug for PackedPatterns<'data>
Sourceยงimpl<'de, 'data> Deserialize<'de> for PackedPatterns<'data>where
    'de: 'data,
 
impl<'de, 'data> Deserialize<'de> for PackedPatterns<'data>where
    'de: 'data,
Sourceยงfn deserialize<D>(
    deserializer: D,
) -> Result<PackedPatterns<'data>, <D as Deserializer<'de>>::Error>where
    D: Deserializer<'de>,
 
fn deserialize<D>(
    deserializer: D,
) -> Result<PackedPatterns<'data>, <D as Deserializer<'de>>::Error>where
    D: Deserializer<'de>,
Sourceยงimpl MaybeAsVarULE for PackedPatterns<'_>
 
impl MaybeAsVarULE for PackedPatterns<'_>
Sourceยงimpl<'data> PartialEq for PackedPatterns<'data>
 
impl<'data> PartialEq for PackedPatterns<'data>
Sourceยงimpl<'a> Yokeable<'a> for PackedPatterns<'static>
 
impl<'a> Yokeable<'a> for PackedPatterns<'static>
Sourceยงtype Output = PackedPatterns<'a>
 
type Output = PackedPatterns<'a>
Self with the 'static replaced with 'a, i.e. Self<'a>Sourceยงfn transform_owned(self) -> <PackedPatterns<'static> as Yokeable<'a>>::Output
 
fn transform_owned(self) -> <PackedPatterns<'static> as Yokeable<'a>>::Output
Sourceยงunsafe fn make(
    this: <PackedPatterns<'static> as Yokeable<'a>>::Output,
) -> PackedPatterns<'static>
 
unsafe fn make( this: <PackedPatterns<'static> as Yokeable<'a>>::Output, ) -> PackedPatterns<'static>
Self<'a>โs lifetime. Read moreSourceยงfn transform_mut<F>(&'a mut self, f: F)
 
fn transform_mut<F>(&'a mut self, f: F)
self between &'a mut Self<'static> and &'a mut Self<'a>,
and pass it to f. Read moreSourceยงimpl<'zf, 'zf_inner> ZeroFrom<'zf, PackedPatterns<'zf_inner>> for PackedPatterns<'zf>
 
impl<'zf, 'zf_inner> ZeroFrom<'zf, PackedPatterns<'zf_inner>> for PackedPatterns<'zf>
Sourceยงfn zero_from(this: &'zf PackedPatterns<'zf_inner>) -> PackedPatterns<'zf>
 
fn zero_from(this: &'zf PackedPatterns<'zf_inner>) -> PackedPatterns<'zf>
C into a struct that may retain references into C.impl<'data> Eq for PackedPatterns<'data>
impl<'data> StructuralPartialEq for PackedPatterns<'data>
Auto Trait Implementationsยง
impl<'data> Freeze for PackedPatterns<'data>
impl<'data> RefUnwindSafe for PackedPatterns<'data>
impl<'data> Send for PackedPatterns<'data>
impl<'data> Sync for PackedPatterns<'data>
impl<'data> Unpin for PackedPatterns<'data>
impl<'data> UnwindSafe for PackedPatterns<'data>
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Sourceยงimpl<T> IntoEither for T
 
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more