pub struct CounterDecl {
pub name: Name,
pub docs: String,
pub default_style: Name,
pub within: Option<Within>,
pub nesting: Option<WithinJoinerSpec>,
}Expand description
A counter, as the feature that declares it contributes it to the service
slot COUNTERS_SLOT.
A counter is a dotted name under which things are counted in document
order, declared by a feature together with the counter it is numbered
within; its value at a reference point is a number with optional
sub-numbers (CounterValue). The declaration gives
the counter’s name, the counter style its numbers are shown in by default,
the counter it is numbered within (Within), and the counter’s nesting
joiner (nesting). The concepts overview presents
counters and counter styles together (counters and counter
styles).
The numbering feature numbers every reference point whose number source
(NumberSource) gives a declared
counter. The feature that owns the point decides whether the point
gives a number source (the numbering depth of the headings feature, the
switch for numbered equations of the mathematics feature); the numbering
feature has no switch of its own.
A counter’s name is dotted and owned by the feature that declares it, like
every name the library registers: flm.headings.section,
flm.math.equation, and a name under a prefix of its own for a counter
that a third party declares. One feature declares a counter, and a name is
declared once per registry; the points of any feature may count in it, and
points of several kinds that count in one counter form one sequence. A
counter style’s name is dotted and owned in the same way
(flm.math.style.equation) and is separate from the counter’s name,
because two features may each declare a counter style for the same
counter.
§Examples
use flm_core::stdlib::features::numbering::{CounterDecl, Within};
// Theorems count from one in every section, and are shown `2.13`.
let decl = CounterDecl::new("example.theorem", "example.style.theorem")
.docs("The theorems of the document.")
.within(Within::parent("flm.headings.section"));
assert!(decl.within.is_some());Fields§
§name: NameThe counter’s name, dotted and owned by the declaring feature, such as
flm.headings.section or flm.math.equation. Two declarations of one
name fail the registry build, and so does a name beginning with
RESERVED_PREFIX.
docs: StringOne sentence saying what the counter counts. The numbering feature keeps it with the declaration and does not display it.
default_style: NameThe name of the counter style in which a point’s number is shown when the point’s number source gives no other. It is also the counter style in which this counter’s number is written as an ancestor until a point advances the counter. A counter style no feature declares fails the registry build.
within: Option<Within>The counter within which this counter is numbered, or None for a
counter numbered within nothing, which is never restarted.
nesting: Option<WithinJoinerSpec>The counter’s nesting joiner: what a point that counts in a
nested scoped instance of this counter writes of the enclosing
instance’s number before its own, or None for
WithinJoinerSpec::Bare, which writes nothing of it.
A scoped instance is an independent sequence of the counter’s values
attached to an enclosing node
(NumberSource::instances).
An instance inside another is numbered within the enclosing instance’s
current value, which the records of its points carry as their last
ancestor. The nesting joiner writes that ancestor, in any of the four
forms a Within may take: Joined(".") and
Template("#{_parent}.") both write 2.(b) for the second item of a
list nested in the second item of another list whose items are written
1, 2, and the default writes (b). The ancestor is written in its
own counter style, so where the enclosing items are written 1., 2.,
Template("#{_parent}") writes 2.(b). In a within template,
#{_parent} and the counter’s own name both refer to the enclosing
instance.
The nesting joiner is compiled when the registry is built, as the
counter’s within is. It may write only
counters that are ancestors of a nested point under every chain of
counters the counter may be numbered within, that is, the counter
itself and the counters it is numbered within; any other counter fails
the registry build.
Implementations§
Source§impl CounterDecl
impl CounterDecl
Sourcepub fn new(name: impl Into<Name>, default_style: impl Into<Name>) -> CounterDecl
pub fn new(name: impl Into<Name>, default_style: impl Into<Name>) -> CounterDecl
Returns a counter named name, shown in the counter style
default_style, numbered within nothing, with no nesting joiner and an
empty description.
Sourcepub fn docs(self, docs: impl Into<String>) -> CounterDecl
pub fn docs(self, docs: impl Into<String>) -> CounterDecl
Builder: sets the sentence that says what the counter counts
(docs). Without the cargo feature docs, the
text is dropped and the field stays empty.
Sourcepub fn within(self, within: Within) -> CounterDecl
pub fn within(self, within: Within) -> CounterDecl
Builder: sets the counter within which this counter is numbered
(within).
Sourcepub fn nesting(self, joiner: WithinJoinerSpec) -> CounterDecl
pub fn nesting(self, joiner: WithinJoinerSpec) -> CounterDecl
Builder: sets the nesting joiner, what a point of a nested scoped
instance writes of the enclosing instance’s number
(nesting).
Trait Implementations§
Source§impl Clone for CounterDecl
impl Clone for CounterDecl
Source§impl Debug for CounterDecl
impl Debug for CounterDecl
impl Eq for CounterDecl
Source§impl Hash for CounterDecl
impl Hash for CounterDecl
Source§impl PartialEq for CounterDecl
impl PartialEq for CounterDecl
impl StructuralPartialEq for CounterDecl
Auto Trait Implementations§
impl Forget for CounterDecl
impl Freeze for CounterDeclwhere
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Name>: Freeze,
impl Move for CounterDecl
impl RefUnwindSafe for CounterDecl
impl Send for CounterDecl
impl Sync for CounterDecl
impl Unpin for CounterDecl
impl UnsafeUnpin for CounterDeclwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Name>: UnsafeUnpin,
impl UnwindSafe for CounterDecl
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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