Skip to main content

Extend

Trait Extend 

Source
pub trait Extend<'a> {
    // Required method
    fn extend(&self, first: &'a str, rest: &'a [&'a str]) -> Vec<Value<'a>>;
}
Expand description

Helpers to extend a parsed Value path with additional string arguments.

This trait is used by the command dispatch code to build a Vec<Value> representing the command path plus the user provided arguments. For example, it allows turning [] into [Value::String("help")] or to append further tokens.

Required Methods§

Source

fn extend(&self, first: &'a str, rest: &'a [&'a str]) -> Vec<Value<'a>>

Extend the current slice of parsed Values with additional string arguments and return a new Vec<Value>.

This is used by the command dispatch code to create a concrete argument vector that contains the existing parsed values followed by the provided first argument and any rest arguments. The returned vector contains cloned/copy variants of the original Values.

§Arguments
  • self - The slice of already-parsed Value arguments to extend.
  • first - The first additional argument to append (becomes a Value::String).
  • rest - Remaining additional arguments to append (each becomes a Value::String).
§Returns

A newly allocated Vec<Value<'a>> containing the original values (as copies) followed by first and the elements of rest converted to Value::String.

Implementations on Foreign Types§

Source§

impl<'a> Extend<'a> for [Value<'a>]

Source§

fn extend(&self, first: &'a str, rest: &'a [&'a str]) -> Vec<Value<'a>>

Implementors§