[−][src]Module proffer::module_gen
Create a Module
which can hold any number of other SrcCode
elements.
Example
use proffer::*; let m = Module::new("foo") .set_is_pub(true) .add_trait(Trait::new("Bar")) .add_function(Function::new("foo")) .add_struct(Struct::new("Thingy")) .add_impl(Impl::new("Thingy")) .add_outer_annotation("#[special_outer_annotation]") .add_inner_annotation("#![special_inner_annotation]") .add_doc("//! Module level docs") .to_owned(); let src_code = m.generate(); let expected = r#" #[special_outer_annotation] pub mod foo { #![special_inner_annotation] //! Module level docs trait Bar { } fn foo() -> () { } struct Thingy { } impl Thingy { } } "#; println!("{}", &src_code); assert_eq!( norm_whitespace(expected), norm_whitespace(&src_code) )
Structs
Module | Represent a module of code |