MCPcopy Create free account
hub / github.com/devashishdxt/cli-table / new

Method new

cli-table-derive/src/context/container.rs:12–36  ·  view source on GitHub ↗
(input: &'a DeriveInput)

Source from the content-addressed store, hash-verified

10
11impl<'a> Container<'a> {
12 pub fn new(input: &'a DeriveInput) -> Result<Self> {
13 let container_attributes = get_attributes(&input.attrs)?;
14
15 let mut crate_name = None;
16
17 for (key, value) in container_attributes {
18 if key.is_ident("crate") {
19 crate_name = Some(match value {
20 Lit::Str(lit_str) => lit_str.parse::<Path>(),
21 bad => Err(Error::new_spanned(
22 bad,
23 "Invalid value for #[table(crate = \"crate_path\")]",
24 )),
25 }?);
26 }
27 }
28
29 let mut container_builder = Container::builder(&input.ident);
30
31 if let Some(crate_name) = crate_name {
32 container_builder.crate_name(crate_name);
33 }
34
35 Ok(container_builder.build())
36 }
37
38 fn builder(name: &'a Ident) -> ContainerBuilder<'a> {
39 ContainerBuilder::new(name)

Callers

nothing calls this directly

Calls 3

get_attributesFunction · 0.85
crate_nameMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected