v0.4.0

ParseError variantv0.1.0

Source
Why text could not be read as a value.
pub variant ParseError {
    Empty,
    InvalidCharacter(uint),
    Overflow(uint)
}

Failure-only: every case is a failure, and each says where in the text it was found. Success is the value a parser returns rather than a case here. Copy, carrying one offset.

Cases

NameDescription
EmptyThere were no bytes to read. The offset is zero, which is both the start of the text and its length.
InvalidCharacter(uint)A byte that is not part of the grammar, or a well-formed value with something after it. The offset is that byte, which is the text's length when the value stopped short.
Overflow(uint)The value is well formed and does not fit the width asked for. The offset is the digit that passed the widest representable magnitude, or the end of the number when the number itself is what does not fit.

Implements ParseFailure

ParseError conforms to ParseFailure.

Offset

pub func Offset(&self) -> uint

Where in the input the failure was found. Borrows the error and leaves it untouched. Cannot fail; runs in constant time and allocates nothing.

Returns: the zero-based UTF-8 byte offset, which is the text's length at end of input

Source