Subcommand

Struct Subcommand 

Source
pub struct Subcommand(pub &'static str, pub CommandFunc);
Expand description

A Molt command that has subcommands is called an ensemble command. In Rust code, the ensemble is defined as an array of Subcommand structs, each one mapping from a subcommand name to the implementing CommandFunc. For more information, see the discussion of command definition in The Molt Book and the interp module.

The tuple fields are the subcommand’s name and implementing CommandFunc.

Tuple Fields§

§0: &'static str§1: CommandFunc

Implementations§

Source§

impl Subcommand

Source

pub fn find<'a>( ensemble: &'a [Subcommand], sub_name: &str, ) -> Result<&'a Subcommand, Exception>

Looks up a subcommand of an ensemble command by name in a table, returning the usual error if it can’t be found. It is up to the ensemble command to call the returned subcommand with the appropriate arguments. See the implementation of the info command for an example.

§TCL Notes
  • In standard TCL, subcommand lookups accept any unambiguous prefix of the subcommand name, as a convenience for interactive use. Molt does not, as it is confusing when used in scripts.

Auto Trait Implementations§

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> 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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.