MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / build_trait_signature

Method build_trait_signature

atomic-semantic/src/parsers/rust.rs:449–471  ·  view source on GitHub ↗

Build a trait signature string.

(&self, node: &Node, source: &str)

Source from the content-addressed store, hash-verified

447
448 /// Build a trait signature string.
449 fn build_trait_signature(&self, node: &Node, source: &str) -> Option<String> {
450 let name_node = node.child_by_field_name("name")?;
451 let name = self.node_text(&name_node, source);
452
453 let generics = node
454 .child_by_field_name("type_parameters")
455 .map(|n| self.node_text(&n, source))
456 .unwrap_or_default();
457
458 let prefix = if self.is_pub(node) {
459 "pub trait"
460 } else {
461 "trait"
462 };
463
464 // Check for supertraits
465 let bounds = node
466 .child_by_field_name("bounds")
467 .map(|n| format!(": {}", self.node_text(&n, source)))
468 .unwrap_or_default();
469
470 Some(format!("{} {}{}{}", prefix, name, generics, bounds))
471 }
472
473 /// Build an impl block signature string.
474 fn build_impl_signature(&self, node: &Node, source: &str) -> Option<String> {

Callers 1

extract_traitMethod · 0.80

Calls 2

is_pubMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected