pub struct UserdefsConfig {
pub definitions: Vec<Definition>,
pub recursion_limit: usize,
}Expand description
The configuration of the userdefs feature: the user definitions
and the expansion depth limit. It is fixed when the registry is built; see
the module documentation.
Build a value with UserdefsConfig::new and the builder methods
definition,
definitions and
recursion_limit, or read it from data
as a UserdefsData and convert it with From.
§Examples
use flm_core::stdlib::features::userdefs::{Definition, UserdefsConfig};
let config = UserdefsConfig::new()
.definition(Definition::macro_("hi", Vec::new()).content("Hello"))
.recursion_limit(4);
assert_eq!(config.definitions.len(), 1);
assert_eq!(config.recursion_limit, 4);Fields§
§definitions: Vec<Definition>The user definitions, in the order they were declared. In data, they are
written in one map per kind (UserdefsData).
recursion_limit: usizeThe expansion depth limit: how many expansions one chain of use sites
may nest before a use site is reported with
flm.userdefs.recursion-limit. The default is
DEFAULT_RECURSION_LIMIT (32).
Implementations§
Source§impl UserdefsConfig
impl UserdefsConfig
Sourcepub fn new() -> UserdefsConfig
pub fn new() -> UserdefsConfig
Returns the default configuration: no definitions, and the default
expansion depth limit (DEFAULT_RECURSION_LIMIT).
Sourcepub fn definition(self, definition: Definition) -> UserdefsConfig
pub fn definition(self, definition: Definition) -> UserdefsConfig
Adds one definition after the ones already declared, and returns the configuration.
Sourcepub fn definitions(
self,
definitions: impl IntoIterator<Item = Definition>,
) -> UserdefsConfig
pub fn definitions( self, definitions: impl IntoIterator<Item = Definition>, ) -> UserdefsConfig
Adds several definitions, in the order given, after the ones already declared, and returns the configuration.
Sourcepub fn recursion_limit(self, limit: usize) -> UserdefsConfig
pub fn recursion_limit(self, limit: usize) -> UserdefsConfig
Sets the expansion depth limit, and returns the configuration.
Sourcepub fn digest_bytes(&self) -> Vec<u8> ⓘ
pub fn digest_bytes(&self) -> Vec<u8> ⓘ
Returns the canonical bytes of the configuration: the input the
userdefs feature gives to the registry digest, and what Hash hashes.
Two configurations give the same bytes exactly when they declare the
same definitions in the same order under the same expansion depth
limit. A definition is written as its name, its kind, its arguments
(each one’s name, the identity of its parser, its parsing mode, its
layout, whether it is declared with an opaque wrapper and its scoped
packages), its template text, the parsing modes it applies in, its
default values, its argument number offset, its block role, its
expansion policy, whether it overrides another feature’s command, and
its extra placeholders (each one’s name and whether it accepts a
substitution argument; Definition::extra_placeholder).
Documentation strings change nothing in a parse and are left out.
Trait Implementations§
Source§impl Clone for UserdefsConfig
impl Clone for UserdefsConfig
Source§impl Debug for UserdefsConfig
impl Debug for UserdefsConfig
Source§impl Default for UserdefsConfig
impl Default for UserdefsConfig
Source§fn default() -> UserdefsConfig
fn default() -> UserdefsConfig
Source§impl From<UserdefsData> for UserdefsConfig
impl From<UserdefsData> for UserdefsConfig
Source§fn from(data: UserdefsData) -> UserdefsConfig
fn from(data: UserdefsData) -> UserdefsConfig
Auto Trait Implementations§
impl !RefUnwindSafe for UserdefsConfig
impl !UnwindSafe for UserdefsConfig
impl Forget for UserdefsConfig
impl Freeze for UserdefsConfig
impl Move for UserdefsConfig
impl Send for UserdefsConfig
impl Sync for UserdefsConfig
impl Unpin for UserdefsConfig
impl UnsafeUnpin for UserdefsConfig
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<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