Expand description
Type-level machinery for building Cow-like
types while avoiding unnecessary copies of `‘static’ or
other shareable references.
The main feature of this crate is the Eso type, which tracks
whether the contained value is ephemeral (i.e. borrowed with any
lifetime), static/shared (i.e. can be held on to indefinitely) or
owned (i.e. can be moved and may be mutably accessed).
In addition, it also statically tracks which of these is possible
at any given point in the code by encoding the information on a
type level using the definitions in the maybe module.
While Eso is perfectly happy working with normal Rust references,
it also provides an abstraction to support a more generalized notion
of reference. The definitions in the borrow module describe
the different operations that are required to use generalized
references.
§Feature flags
§allow-unsafe: Allow usage of unsafe Rust
This feature is active by default.
Eso contains two usages of unsafe, which make the No
type implement Send and Sync irrespective of its type
parameter.
This should be safe since no value of the No type can ever exist
and it therefore cannot participate in any races or memory safety violations.
Nonetheless, if you want to disallow usage of unsafe,
turn off the default features in your Cargo.toml:
[dependencies.eso]
version = "0.0.2"
default-features = falseModules§
- borrow
- The
TakeandBorrowtraits abstract over the duality between owned and borrowed types, much in the same way as the standard-libraryBorrowandToOwnedtraits do. - eso
- The
Esotype and associated traits for advanced reference wrangling. - maybe
- The
Maybetrait and its two implementationsAnandNodescribe a compile-time optional value. - shorthand
- Shorthand type aliases to refer to
Esowith different combinations of type parameters. - unify
- Type-level machinery to allow
Eso::unifyto work.
Structs§
Enums§
- Eso
- A three-way choice between an Ephemeral reference (i.e.
with a lifetime that is not
'static), a Static reference and an Owned value.