Skip to main content

Result

Type Alias Result 

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

A specialized Result type for StaticWeaver operations.

This type is used throughout the StaticWeaver library for any operation that can produce an EngineError.

§Examples

use staticweaver_core::error::Result;
use staticweaver_core::EngineError;

fn check(input: &str) -> Result<usize> {
    if input.is_empty() {
        Err(EngineError::InvalidTemplate("empty".to_string()))
    } else {
        Ok(input.len())
    }
}

assert_eq!(check("hello").unwrap(), 5);
assert!(check("").is_err());

Aliased Type§

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

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(EngineError)

Contains the error value