Skip to main content

Parser

Struct Parser 

Source
pub struct Parser {
    pub source_file: SourceFile,
    pub tokens: Vec<Token>,
    pub current: usize,
    pub ast_arena: Ast,
    pub record_names: HashSet<String>,
    pub tag_names: HashSet<String>,
}
Expand description

Parses a flat list of tokens and produces a Vec<Statement>.

The parser owns the token stream and advances through it with a single current index cursor. All sub-parsers borrow self mutably and call the cursor primitives (peek, advance, match_type, etc.) defined in this module.

Construct via Parser::parse - there is no public new.

Fields§

§source_file: SourceFile

the source file (text + name) carried for error reports

§tokens: Vec<Token>

the full token list produced by the lexer, including the terminal [TokenType::Eof]

§current: usize

index of the token currently being examined (the “read head”)

§ast_arena: Ast§record_names: HashSet<String>

Names of record types declared so far, used to disambiguate Name { ... } struct literals from block bodies (e.g. if x { }).

§tag_names: HashSet<String>

Names of tag (enum) types declared so far, used to recognize Name.Variant as an enum variant reference rather than a field access.

Implementations§

Source§

impl Parser

Source

pub fn parse_comparsion(&mut self) -> Result<ExprId, Error>

Parses comparison and compound-assignment operators: <, <=, >, >=, +=, -=, *=, /=.

Compound-assignment operators (+= etc.) are desugared in-place: when the left-hand side is a plain ExpressionKind::Identifier, they expand to an ExpressionKind::Assign whose value is the corresponding ExpressionKind::Binary. If the LHS is not a simple identifier the operator is treated as a plain binary expression (the checker will reject it later if needed).

Source§

impl Parser

Source

pub fn parse_equality(&mut self) -> Result<ExprId, Error>

Parses == and != binary expressions (lowest precedence).

Left-associative: a == b != c is (a == b) != c.

Source§

impl Parser

Source

pub fn parse_factor(&mut self) -> Result<ExprId, Error>

Parses multiplicative expressions: * and /.

Left-associative: a * b / c is (a * b) / c.

Source§

impl Parser

Source

pub fn parse_logical(&mut self) -> Result<ExprId, Error>

Source§

impl Parser

Source

pub fn parse_postfix( &mut self, expr: ExprId, start: Span, ) -> Result<ExprId, Error>

Parses zero or more postfix method-call chains on expr.

After any primary or sub-expression is built, this function consumes repeated .method(args) suffixes, producing a left-associative chain of ExpressionKind::MethodCall nodes. Method names may themselves be namespaced (obj.module::method()).

Returns expr unchanged when the next token is not ..

§Errors

Returns an error if . is not followed by a valid identifier, or if the argument list is not opened with (.

Source§

impl Parser

Source

pub fn parse_primary(&mut self) -> Result<ExprId, Error>

Parses a primary expression - the highest-precedence, non-recursive forms.

Handles (in order):

  • Identifiers - plain names, module paths (a::b::c), function calls (f(args)), variable assignments (x = expr), index access (arr[i]), chained index access (arr[i][j]), index-assign (arr[i] = expr), and call-on-index (fns[0](args)).
  • Array literals - [a, b, c]
  • Integer literals - 42
  • Byte literals - 0b style byte values
  • String literals - "hello"
  • Character literals - 'x'
  • Boolean literals - true / false
  • Float literals - 3.14
  • Null - the null keyword
  • Grouped expressions - (expr)
  • Lambda expressions - fn(params) -> T { body }

Every matched form is then passed through parse_postfix to handle any trailing method-call chains.

§Errors

Returns an error with the message "expected expression" if none of the above forms match the current token.

Source§

impl Parser

Source

pub fn parse_struct_literal( &mut self, name: String, start: Span, ) -> Result<ExprId, Error>

Parses the body of a struct literal after Name has already been consumed. start is the span of the beginning of the Name token.

Source§

impl Parser

Source

pub fn parse_term(&mut self) -> Result<ExprId, Error>

Parses additive expressions: + and -.

Left-associative: a + b - c is (a + b) - c.

Source§

impl Parser

Source

pub fn parse_unary(&mut self) -> Result<ExprId, Error>

Parses unary prefix expressions: ! (logical not) and - (negation).

Right-associative by recursion: --x parses as -(-(x)). Falls through to parse_primary when no prefix operator is present.

Source§

impl Parser

Source

pub fn parse_expression(&mut self) -> Result<ExprId, Error>

Entry point for expression parsing. Delegates to parse_equality.

Source§

impl Parser

Source

pub fn parse( tokens: Vec<Token>, source_file: SourceFile, ) -> Result<(Ast, Vec<Statement>), Error>

Entry point: consumes tokens and returns a fully-parsed statement list.

Drives the top-level parse loop, calling parse_statement_to_ast until [TokenType::Eof] is reached.

§Errors

Returns the first Error encountered; parsing stops immediately.

Source

pub fn err(&self, message: impl Into<String>, span: Span) -> Error

Constructs a Reason::Parse error anchored at span with the source file already attached, ready to be returned from any parse method.

Source§

impl Parser

Source

pub fn parse_const_declartion( &mut self, start: Span, ) -> Result<Statement, Error>

Parses a CONST constant declaration.

Called after CONST has been consumed. Handles two forms:

§Errors

Returns an error if the type, name, =, or initialiser expression is missing or malformed.

Source

fn parse_const_declartion_scalar( &mut self, start: Span, ) -> Result<Statement, Error>

Source§

impl Parser

Source

pub fn parse_for(&mut self, start: Span) -> Result<Statement, Error>

Parses a for statement in one of its three forms.

Called after for has been consumed. Dispatches on the next token:

§Errors

Returns an error for invalid range elements (non-integer), missing commas in C-style headers, or unrecognised for syntax.

Source§

impl Parser

Source

pub fn parse_function( &mut self, start: Span, attribute: Option<FunctionAttribute>, ) -> Result<Statement, Error>

Parses a named function declaration.

Called after fn has been consumed (either by parse_statement_to_ast or parse_entry_attribute). Reads:

  1. The function name (identifier).
  2. A (-delimited, comma-separated parameter list of T name pairs.
  3. An optional -> T return type annotation (defaults to TypeAnnotation::Null when absent).
  4. The function body via parse_block.

Produces StatementKind::FunctionDeclaration.

§Parameters
  • start - the span of the fn token, used as the start of the overall span.
  • is_entry - true when the function was marked with !#[entry].
§Errors

Returns an error if the function name, a parameter name, or the body block are missing or malformed.

Source§

impl Parser

Source

pub fn parse_if(&mut self, start: Span) -> Result<Statement, Error>

Parses an if statement, including any else if / else tail.

Called after if has been consumed. Reads:

  1. The condition expression.
  2. The {-delimited if-body via parse_block.
  3. An optional else tail - either another if (recursed) or a plain else { … } block (condition is None).

Blank lines between the closing } and else are skipped.

Produces StatementKind::Conditional with one or two StatementKind::ConditionalBranch children.

Source§

impl Parser

Source

pub fn parse_import(&mut self, start: Span) -> Result<Statement, Error>

Parses a get import statement.

Called after get has been consumed. Dispatches on the tokens that follow the first identifier:

§Errors

Returns an error if an identifier is missing after get, ::, ,, or from, or if from itself is absent in the named-import form.

Source§

impl Parser

Source

pub fn parse_match(&mut self, start: Span) -> Result<Statement, Error>

Source§

impl Parser

Source

pub fn parse_record_declaration( &mut self, start: Span, ) -> Result<Statement, Error>

Parses a record declaration.

Called after record has been consumed. Reads the record name, then a {-delimited, comma-separated list of T name field pairs.

Produces StatementKind::RecordDeclaration.

§Errors

Returns an error if the record name, a field type/name, or the closing } are missing or malformed.

Source§

impl Parser

Source

pub fn parse_tag_declaration(&mut self, start: Span) -> Result<Statement, Error>

Parses a tag declaration.

Called after tag has been consumed. Reads the tag name, then a {-delimited, comma-separated list of variant names.

Produces StatementKind::TagDeclaration.

§Errors

Returns an error if the tag name, a variant name, or the closing } are missing or malformed.

Source§

impl Parser

Source

pub fn parse_variable_declartion( &mut self, start: Span, ) -> Result<Statement, Error>

Parses a dec variable declaration.

Called after dec has been consumed. Handles two forms:

§Errors

Returns an error if the type, name, =, or initialiser expression is missing or malformed.

Source

fn parse_variable_declartion_scalar( &mut self, start: Span, ) -> Result<Statement, Error>

Source§

impl Parser

Source

pub fn parse_while(&mut self, start: Span) -> Result<Statement, Error>

Parses a while loop.

Called after while has been consumed. Reads the loop condition as an expression, then the loop body via parse_block, and produces StatementKind::While.

Source§

impl Parser

Source

pub fn parse_statement_to_ast(&mut self) -> Result<Statement, Error>

Dispatches the current token to the appropriate statement sub-parser.

TokenAction
Newlineskip - emits a no-op Expression(0) placeholder
getparse_import
decparse_variable_declaration
CONSTparse_const_declaration
whileparse_while
forparse_for
ifparse_if
fnparse_function
!#parse_entry_attribute
returninline - parses optional return value
breakinline - emits StatementKind::Break
continueinline - emits StatementKind::Continue
anything elseparse_expression wrapped in StatementKind::Expression
Source

pub fn parse_block(&mut self) -> Result<Vec<Statement>, Error>

Parses a brace-delimited block { stmts* } into a Vec<Statement>.

Consumes the opening {, then repeatedly calls parse_statement_to_ast until } or TokenType::Eof is reached. Blank lines (newlines) inside the block are skipped.

§Errors

Returns an error if the opening { is missing.

Source

fn parse_entry_attribute(&mut self, start: Span) -> Result<Statement, Error>

Parses a !#[entry] attribute and the fn declaration that follows it.

The !# token has already been consumed by [parse_statement_to_ast] before this is called. Expects [entry] then a function declaration, which is forwarded to parse_function with is_entry = true.

§Errors

Returns an error if [, the entry identifier, ], or fn are missing or in the wrong order.

Source§

impl Parser

Source

pub fn parse_type(&mut self, is_mut: bool) -> Result<TypeAnnotation, Error>

Parses a type keyword into a TypeAnnotation.

The is_mut flag controls which annotation variant is produced:

is_mutproduced variant
trueInt, Float, Bool, String, Byte, Char, Fn, Array(T)
falseCInt, CFloat, CBool, CString, CByte, CChar, Fn, CArray(T)

The C* variants represent constant (immutable) bindings and are used by the const declaration path.

For array[T] the inner element type is parsed recursively.

§Errors

Returns an error if the current token is not a recognised type keyword.

Source§

impl Parser

Source

pub fn peek_span(&self) -> Span

Returns the Span of the token at the current read head without consuming it.

Source

pub fn previous_span(&self) -> Span

Returns the Span of the most recently consumed token.

Returns the span of tokens[0] when called before any advance.

Source

pub fn is_at_end(&self) -> bool

Returns true when the read head sits on TokenType::Eof, indicating the end of the token stream.

Source

pub fn advance(&mut self)

Advances the read head by one token, unless already at TokenType::Eof.

Source

pub fn peek(&self) -> TokenType

Returns the TokenType at the current read head without consuming it.

Source

pub fn previous(&self) -> TokenType

Returns the TokenType of the most recently consumed token.

§Panics

Panics if called before any token has been consumed (current == 0).

Source

pub fn check(&self, token_type: &TokenType) -> bool

Returns true if the token at the read head matches token_type.

Literal-carrying variants (NumberLiteral, StringLiteral, etc.) are matched by variant tag only - the inner value is ignored. Does not consume the token.

Source

pub fn match_type(&mut self, types: &[TokenType]) -> bool

Tries each variant in types against the current token via check.

On the first match the token is consumed via advance and true is returned. Returns false without advancing if nothing matches.

Source

pub fn parse_param_type(&mut self) -> Result<TypeAnnotation, Error>

Parses a single type keyword (or array[T]) as a function/lambda parameter type annotation.

Called when a type is expected in a parameter list position. For the array keyword the inner element type is parsed recursively via nested_array_type.

§Errors

Returns an error if the current token is not a recognised type keyword.

Source

pub fn nested_array_type(&mut self) -> Result<Box<TypeAnnotation>, Error>

Parses the [T] suffix of an array[T] type annotation, returning a boxed TypeAnnotation::Array.

Expects the array keyword to have already been consumed. Reads [, the inner element type (via parse_param_type), then ].

§Errors

Returns an error if [ or ] are missing, or if the inner type is invalid.

Source

pub fn nested_map_type(&mut self) -> Result<Box<TypeAnnotation>, Error>

Source

pub fn set_type(&mut self) -> Result<Box<TypeAnnotation>, Error>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Paint for T
where T: ?Sized,

§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling [Attribute] value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi [Quirk] value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the [Condition] value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new [Painted] with a default [Style]. Read more
§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
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.