Crate wagon_utils

Source
Expand description

Utility methods for the WAGon suite of libraries.

Provides a number of simple functions, as well as a trait version of std::iter::Peekable and a fallible version of itertools::Itertools.

Macros§

string_vec
Same as vec! but calls to_string() on all the elements.

Structs§

ConversionError
We failed to convert from some thing to another thing.
SplitError
An struct for when split_to_twople fails.
UnexpectedEnd
Error struct to represent we’ve reached the end of an iterator. Used for ResultNext.

Traits§

ErrorReport
A trait for Errors that return a specific message and span structure.
FallibleItertools
A slightly modified version of the Itertools trait which returns Result instead.
Peek
A trait version of the functionality that Peekable provides.
ResultNext
Quickly get a result from an iterator of Results.
ResultPeek
Same as ResultNext but for things that implement Peek.
Spannable
Trait for objects that provide Span information. Used for error messaging.
UnsafeNext
Forcibly extract an item out of an iterator of Results.
UnsafePeek
Same as UnsafeNext but intended for iterators that allow peeking (such as Peekable).

Functions§

comma_separated
Given a list of objects that implement std::fmt::Display. Returns a comma separated string.
comma_separated_with_or
Given a vector of strings, return a string that has all the values joined by a ,. Except for the last which is joined by or.
comma_separated_with_or_str
Same as comma_separated_with_or, but takes a vector of &str instead.
normalize_to_probabilities
Given a list of values, attempt to normalize them based on their sum.
rem_first_and_last_char
Removes the first and last character of a string.
rem_first_char
Removes the first character of a string.
rem_first_char_n
Removes the first n characters of a string.
rem_last_char
Removes last character of a string.
remove_whitespace
Removes all whitespace from a string.
split_to_twople
Given string and a character. Attempt to split the string at that character into 2 distinct parts.

Type Aliases§

Span
The definition of a Span as used throughout WAGon.