Struct string_cache_codegen::AtomType
[−]
[src]
pub struct AtomType { /* fields omitted */ }
A builder for a static atom set and relevant macros
Methods
impl AtomType
[src]
fn new(path: &str, macro_name: &str) -> Self
Constructs a new static atom set builder
path
is a path within a crate of the atom type that will be created.
e.g. "FooAtom"
at the crate root or "foo::Atom"
if the generated code
is included in a foo
module.
macro_name
must end with !
.
For example, AtomType::new("foo::FooAtom", "foo_atom!")
will generate:
pub type FooAtom = ::string_cache::Atom<FooAtomStaticSet>; pub struct FooAtomStaticSet; impl ::string_cache::StaticAtomSet for FooAtomStaticSet { // ... } #[macro_export] macro_rules foo_atom { // Expands to: $crate::foo::FooAtom { … } }
fn atom(&mut self, s: &str) -> &mut Self
Adds an atom to the builder
fn atoms<I>(&mut self, iter: I) -> &mut Self where
I: IntoIterator,
I::Item: AsRef<str>,
I: IntoIterator,
I::Item: AsRef<str>,
Adds multiple atoms to the builder
fn write_to<W>(&mut self, destination: W) -> Result<()> where
W: Write,
W: Write,
Write generated code to destination
.
fn write_to_file(&mut self, path: &Path) -> Result<()>
Create a new file at path
and write generated code there.
Typical usage:
.write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join("foo_atom.rs"))