pub struct ArgCode { /* private fields */ }Expand description
An argument code that has been read: the code’s text, as written, and the
standard argument kind (ArgStdKind) it stands for. An argument code is
a short text, such as { or r(), that settings given as data write for
the syntax of an argument; the module documentation lists the
codes.
ArgCode::read is the only way to make one, so its text and its kind
always agree. An argument declaration (ArgDef) is made from it through
From, without reading the code again, and keeps it: ArgDef::code
gives the code’s text and ArgDef::arg_code the ArgCode itself. A
declaration keeps the text as well as the kind because several codes
stand for one kind ({ and m, * and t*), and a declaration written
back as data shows the code its author wrote.
Implementations§
Source§impl ArgCode
impl ArgCode
Sourcepub fn read(code: &str) -> Result<ArgCode, ArgCodeError>
pub fn read(code: &str) -> Result<ArgCode, ArgCodeError>
Reads code as an argument code, one of those listed in the module
documentation.
This is the only reader of the codes: arg_def_from_code, and
through it every reader of settings given as data, reads its codes
with it.
§Errors
An ArgCodeError for a text that is no code
(ArgCodeProblem::Unknown) and for a code lacking the characters it
takes (ArgCodeProblem::Incomplete: r(, t, e{}).
§Examples
use flm_core::lang::mint::{ArgCode, ArgCodeProblem, ArgDef, ArgStdKind};
let code = ArgCode::read("r()").unwrap();
assert_eq!(code.as_str(), "r()");
assert_eq!(code.kind(), &ArgStdKind::DelimitedGroup { open: '(', close: ')' });
assert_eq!(ArgDef::from(code).code(), Some("r()"));
assert_eq!(ArgCode::read("q").unwrap_err().problem, ArgCodeProblem::Unknown);
assert_eq!(ArgCode::read("r(").unwrap_err().problem, ArgCodeProblem::Incomplete);Sourcepub fn kind(&self) -> &ArgStdKind
pub fn kind(&self) -> &ArgStdKind
The standard kind the code stands for.
Trait Implementations§
impl Eq for ArgCode
Source§impl From<ArgCode> for ArgDef
The declaration of an argument read by the standard kind code stands
for, with no name, inline layout and no scoped package, which keeps the
code (ArgDef::code, ArgDef::arg_code). The code is not read again.
impl From<ArgCode> for ArgDef
The declaration of an argument read by the standard kind code stands
for, with no name, inline layout and no scoped package, which keeps the
code (ArgDef::code, ArgDef::arg_code). The code is not read again.
impl StructuralPartialEq for ArgCode
Auto Trait Implementations§
impl !RefUnwindSafe for ArgCode
impl !UnwindSafe for ArgCode
impl Forget for ArgCode
impl Freeze for ArgCodewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<char>: Freeze,
PhantomData<TackOnField>: Freeze,
impl Move for ArgCode
impl Send for ArgCode
impl Sync for ArgCode
impl Unpin for ArgCode
impl UnsafeUnpin for ArgCodewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<char>: UnsafeUnpin,
PhantomData<TackOnField>: UnsafeUnpin,
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