Skip to main content

Result

Type Alias Result 

Source
pub type Result<T> = Result<T, HtmlError>;
Expand description

Type alias for a result using the HtmlError error type.

This type alias makes it more convenient to work with Results throughout the library, reducing boilerplate and improving readability.

§Examples

use html_generator::error::{HtmlError, Result};

fn parse(input: &str) -> Result<usize> {
    if input.is_empty() {
        return Err(HtmlError::InvalidInput("empty".into()));
    }
    Ok(input.len())
}

assert_eq!(parse("hi").unwrap(), 2);
assert!(parse("").is_err());

Aliased Type§

pub enum Result<T> {
    Ok(T),
    Err(HtmlError),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(HtmlError)

Contains the error value