MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / strip_turbofish

Function strip_turbofish

codegraph-kernel/src/rustlang.rs:1708–1738  ·  view source on GitHub ↗

A callee path without its turbofish type arguments: `Vec:: ::new` → `Vec::new`. The brackets nest (`:: >`), and the `>` of a `->` is no closing one (`:: u8>`). Mirrors stripRustTurbofish in TreeSitterExtractor: both emit the same bytes.

(text: &str)

Source from the content-addressed store, hash-verified

1706/// no closing one (`::<fn() -> u8>`). Mirrors stripRustTurbofish in
1707/// TreeSitterExtractor: both emit the same bytes.
1708fn strip_turbofish(text: &str) -> String {
1709 if !text.contains("::<") {
1710 return text.to_string();
1711 }
1712 let chars: Vec<char> = text.chars().collect();
1713 let mut out = String::with_capacity(text.len());
1714 let mut i = 0;
1715 while i < chars.len() {
1716 if chars[i] == ':' && i + 2 < chars.len() && chars[i + 1] == ':' && chars[i + 2] == '<' {
1717 let mut depth = 0i32;
1718 let mut j = i + 2;
1719 while j < chars.len() {
1720 let c = chars[j];
1721 if c == '<' {
1722 depth += 1;
1723 } else if c == '>' && chars[j - 1] != '-' {
1724 depth -= 1;
1725 if depth == 0 {
1726 break;
1727 }
1728 }
1729 j += 1;
1730 }
1731 i = j + 1;
1732 continue;
1733 }
1734 out.push(chars[i]);
1735 i += 1;
1736 }
1737 out
1738}
1739
1740/// LITERAL_RECEIVER_TYPES (shared table).
1741fn is_literal_receiver(kind: &str) -> bool {

Callers 1

extract_callMethod · 0.85

Calls 3

lenMethod · 0.80
pushMethod · 0.80
collectMethod · 0.45

Tested by

no test coverage detected