Skip to content
CryoCryo home
Stdlibtest

error

import std::test::error; · source

Types

TestError

type enum TestError {
    Failed(String);
    Other(String);
}

implement enum TestError {
    message_str(&this) -> Str;
    static failed(message: Str) -> TestError;
    static other(message: Str) -> TestError;
}

Failed is an assertion that did not hold; Other is everything else. It owns its message, so it carries a drop.

Variants

VariantNotes
Failed(String)A user assertion failed. Carries the assertion message.
Other(String)Any other reason a test could not produce a definitive result: I/O error during setup, environment problem, etc.

Constructors

static failed(message: Str) -> TestError;

Construct a Failed from a borrowed Str. Allocates an owned copy of the message; the test function's source string can safely outlive the resulting TestError value.

static other(message: Str) -> TestError;

Construct an Other from a borrowed Str. Allocates an owned copy of the message.

Methods

message_str(&this) -> Str;

Borrowed view into the variant's message. Cheap: no allocation, no Drop interaction. Valid for the lifetime of the TestError. Use this when you only need to display or compare the message.

Trait implementations

implement trait Drop for enum TestError
implement trait Display for enum TestError