flextablev0.1.0

API Reference

Error

The error enum and Result alias returned by fallible table operations.

Error#

pub enum Error {
    NilKey,
    InvalidKey,
    TypeMismatch { expected: &'static str, found: &'static str },
    Incomparable { left: &'static str, right: &'static str },
    PositionOutOfBounds { position: i64, len: usize },
}

Implements: Debug, Clone, PartialEq, Eq, Display, std::error::Error.

Variants#

VariantMeaningDisplay
NilKeynil was used as a keynil cannot be used as a table key
InvalidKeya NaN key, or a key passed to next that is not in the tablevalue cannot be used as a table key
TypeMismatchan operation needed another type (concat on a non-string, non-number element)type mismatch: expected …, found …
Incomparabletwo values have no order (sort, try_cmp)attempt to compare … with …
PositionOutOfBoundsa sequence position outside the allowed range; position is the 1-based position given, len the sequence length at the timeposition … out of bounds (length …)

Type names in TypeMismatch and Incomparable come from Value::type_name.

Result#

pub type Result<T> = std::result::Result<T, Error>;

Returned by every fallible table operation. See Error Handling for which methods return which errors.

Rust
use flextable::{table, Error};

let t = table!["a"];
match t.insert(5, "b") {
    Err(Error::PositionOutOfBounds { position, len }) => {
        assert_eq!((position, len), (5, 1));
    }
    other => panic!("unexpected: {other:?}"),
}