[][src]Crate substr

Encapsulates the concept of a substring of a certain length found at a given offset, which can be useful when this information cannot be directly coupled to the lifetime of the orignal string it was derived from. This can be useful, for example, when the section of a string which caused a parsing error must be reported in a manner which must survive the lifetime of the original parsed string.

This may sound like an odd set of requirements, but it notably occurs when implementing an external trait (which cannot be modified to take a lifetime parameter) which contains a function which takes a &str -- like, say, std::str::FromStr.

Structs

Substr

A Substr represents the position of a child string within a parent, and can be converted back to its original form if the parent &str it was derived from is still avaliable.

Constants

EMPTY

Handy default Substr whose length and offset are both zero. Returned via Substr::default().

Traits

FindSubstr

A helper trait to make converting a &str to a Substr easier. Returns an Option instead of a Result to match the behavior of str::find().