Skip to main content

CounterStyle

Struct CounterStyle 

Source
pub struct CounterStyle { /* private fields */ }
Expand description

A counter style compiled against the built language: what a number is written with.

It is built from a CounterStyleDecl by compile or compile_with, holds the parsed form of every text of the declaration and the compiled number writer, and is passed to format() and format_many. The counter table holds the compiled counter styles of a registry (Counters::style).

Implementations§

Source§

impl CounterStyle

Source

pub fn name(&self) -> &Name

Returns the counter style’s name, as the declaration gave it.

Source

pub fn warnings(&self) -> &[FlmDiagnostic]

Returns the diagnostics that the counter style’s texts raised when they were parsed. None of them is an error, since a text that parses with an error is refused instead. The numbering feature adds them to the registry’s build diagnostics.

Source

pub fn with_number_format( &self, template: &NumberTemplate, lang: &BuiltLang, language: &TemplateLanguage, ) -> Result<CounterStyle, StyleError>

Returns a derived counter style: this counter style with its number format replaced by template, with the same name, sub-levels, words, delimiters, join texts, choices and number writer.

Only template is compiled; every other part is shared with this counter style. The numbering stage uses it for a point that carries a number template of its own (NumberSource::number_format): the point’s record holds the derived counter style, so that the point’s number and every reference to it are written in it. The lists feature also writes an item’s label through a derived counter style (Counters::format_in_style). The warnings of the derived counter style are this counter style’s, followed by those template raised.

§Errors

The StyleError of a template that does not compile, as CounterStyleDecl::compile_with reports it for a declaration’s number template.

Source

pub fn declares_variant(&self, name: &str) -> bool

Returns whether the counter style declares the variant name of the prefix words (PrefixWords::variants).

A number asked for in a variant the counter style does not declare is written with the default words; a caller that reports such a request, as the refs feature does, checks it with this method.

Source

pub fn sub_level_count(&self) -> usize

Returns how many sub-levels the counter style declares: the depth of the deepest sub-number it can write, counting the first sub-level as 1.

A value that carries a non-zero sub-number deeper than that cannot be written in this counter style; the numbering stage checks this when it makes a record, not when the number is shown.

Source

pub fn literal(&self, text: &str) -> Result<Arc<NodeTree<Flm>>, FormatError>

Returns text as a small tree of content, built as the characters of a number are: one text node attributed to the counter style’s source.

A caller that writes several numbers itself builds the text between two of them with this method: everything a reader sees is content, not characters, and this module provides the only way to build content from computed characters. The call runs on a worker thread.

§Errors

FormatError::NestingTooDeep or FormatError::Failed when the content could not be built.

Trait Implementations§

Source§

impl Debug for CounterStyle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for CounterStyle

§

impl !UnwindSafe for CounterStyle

§

impl Forget for CounterStyle

§

impl Freeze for CounterStyle
where *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze, *const u8 is !null: Freeze, PhantomData<NumberPart>: Freeze, PhantomData<u8>: Freeze, *const ArcInner<Source<FlmOrigin>> is !null: Freeze, PhantomData<ArcInner<Source<FlmOrigin>>>: Freeze, *const ArcInner<NodeTree<Flm>> is !null: Freeze, PhantomData<ArcInner<NodeTree<Flm>>>: Freeze, *const LeafNode<NodeId, PlaceholderRef> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(NodeId, PlaceholderRef)>>: Freeze, PhantomData<Diagnostic<FlmOrigin>>: Freeze, PhantomData<NumberFormat>: Freeze, *const ArcInner<Vec<CompiledSubLevel>> is !null: Freeze, PhantomData<ArcInner<Vec<CompiledSubLevel>>>: Freeze, *const ArcInner<CompiledWords> is !null: Freeze, PhantomData<ArcInner<CompiledWords>>: Freeze, *const ArcInner<CompiledJoin> is !null: Freeze, PhantomData<ArcInner<CompiledJoin>>: Freeze, *const ArcInner<dyn CompiledNumberWriter> is !null: Freeze, PhantomData<ArcInner<dyn CompiledNumberWriter>>: Freeze, *const ArcInner<ParsingState<Flm>> is !null: Freeze, PhantomData<ArcInner<ParsingState<Flm>>>: Freeze,

§

impl Move for CounterStyle

§

impl Send for CounterStyle
where Arc<str>: Send, RawVecInner: Send, Arc<NodeTree<Flm>>: Send, Arc<Source<FlmOrigin>>: Send, NodeRef<Owned, NodeId, PlaceholderRef, LeafOrInternal>: Send, BoxRaw<(NodeId, PlaceholderRef)>: Send, BoxRaw<dyn DiagnosticData>: Send, Arc<Vec<CompiledSubLevel>>: Send, Arc<CompiledWords>: Send, Arc<CompiledJoin>: Send, Arc<dyn CompiledNumberWriter>: Send, Arc<ParsingState<Flm>>: Send,

§

impl Sync for CounterStyle
where Arc<str>: Sync, RawVecInner: Sync, Arc<NodeTree<Flm>>: Sync, Arc<Source<FlmOrigin>>: Sync, NodeRef<Owned, NodeId, PlaceholderRef, LeafOrInternal>: Sync, BoxRaw<(NodeId, PlaceholderRef)>: Sync, BoxRaw<dyn DiagnosticData>: Sync, Arc<Vec<CompiledSubLevel>>: Sync, Arc<CompiledWords>: Sync, Arc<CompiledJoin>: Sync, Arc<dyn CompiledNumberWriter>: Sync, Arc<ParsingState<Flm>>: Sync,

§

impl Unpin for CounterStyle
where Arc<str>: Unpin, *const u8 is !null: Unpin, Arc<NodeTree<Flm>>: Unpin, Arc<Source<FlmOrigin>>: Unpin, *const LeafNode<NodeId, PlaceholderRef> is !null: Unpin, Box<(NodeId, PlaceholderRef)>: Unpin, Box<dyn DiagnosticData>: Unpin, Arc<Vec<CompiledSubLevel>>: Unpin, Arc<CompiledWords>: Unpin, Arc<CompiledJoin>: Unpin, Arc<dyn CompiledNumberWriter>: Unpin, Arc<ParsingState<Flm>>: Unpin,

§

impl UnsafeUnpin for CounterStyle
where *const ArcInner<str> is !null: UnsafeUnpin, PhantomData<ArcInner<str>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<NumberPart>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<Source<FlmOrigin>> is !null: UnsafeUnpin, PhantomData<ArcInner<Source<FlmOrigin>>>: UnsafeUnpin, *const ArcInner<NodeTree<Flm>> is !null: UnsafeUnpin, PhantomData<ArcInner<NodeTree<Flm>>>: UnsafeUnpin, *const LeafNode<NodeId, PlaceholderRef> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(NodeId, PlaceholderRef)>>: UnsafeUnpin, PhantomData<Diagnostic<FlmOrigin>>: UnsafeUnpin, PhantomData<NumberFormat>: UnsafeUnpin, *const ArcInner<Vec<CompiledSubLevel>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<CompiledSubLevel>>>: UnsafeUnpin, *const ArcInner<CompiledWords> is !null: UnsafeUnpin, PhantomData<ArcInner<CompiledWords>>: UnsafeUnpin, *const ArcInner<CompiledJoin> is !null: UnsafeUnpin, PhantomData<ArcInner<CompiledJoin>>: UnsafeUnpin, *const ArcInner<dyn CompiledNumberWriter> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn CompiledNumberWriter>>: UnsafeUnpin, *const ArcInner<ParsingState<Flm>> is !null: UnsafeUnpin, PhantomData<ArcInner<ParsingState<Flm>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.