docs.rs failed to build illicit-0.9.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
illicit-1.1.2
Type-indexed scoped singletons, propagated through an implicit backing context.
Requiring references from the environment
The from_env
macro provides an attribute for functions that require access to a singleton in
their environment. Here, the contrived function requires a u8
to add one to:
#[illicit::from_env(num: &u8)]
fn env_num_plus_one() -> u8 {
num + 1
}
illicit::child_env!(u8 => 1).enter(|| {
assert_eq!(env_num_plus_one(), 2u8);
});
This provides convenient sugar for values stored in the current Env
as an alternative to
thread-locals or a manually propagated context object. However this approach incurs a
significant cost in that the following code will panic without the right type having been added
to the environment:
# #[illicit::from_env(num: &u8)]
# fn env_num_plus_one() -> u8 {
# num + 1
# }
// thread 'main' panicked at 'expected a value from the environment, found none'
env_num_plus_one();
See the attribute's documentation for more details, and please consider whether this is appropriate for your use case before taking it on as a dependency.