MCPcopy Index your code
hub / github.com/RustPython/RustPython / pytraverse_arg

Function pytraverse_arg

crates/derive-impl/src/pytraverse.rs:13–33  ·  view source on GitHub ↗

only accept `#[pytraverse(skip)]` for now

(attr: &Attribute)

Source from the content-addressed store, hash-verified

11
12/// only accept `#[pytraverse(skip)]` for now
13fn pytraverse_arg(attr: &Attribute) -> Option<Result<TraverseAttr>> {
14 if !attr.path().is_ident(ATTR_TRAVERSE) {
15 return None;
16 }
17 let ret = || {
18 let mut skip = false;
19 attr.parse_nested_meta(|meta| {
20 if meta.path.is_ident("skip") {
21 if skip {
22 return Err(meta.error("already specified skip"));
23 }
24 skip = true;
25 } else {
26 return Err(meta.error("unknown attr"));
27 }
28 Ok(())
29 })?;
30 Ok(TraverseAttr { skip })
31 };
32 Some(ret())
33}
34
35fn field_to_traverse_code(field: &Field) -> Result<TokenStream> {
36 let pytraverse_attrs = field

Callers

nothing calls this directly

Calls 5

retFunction · 0.85
ErrClass · 0.50
SomeClass · 0.50
pathMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected