Build a trait signature string.
(&self, node: &Node, source: &str)
| 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> { |
no test coverage detected