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

Function strip_turbofish

codegraph-kernel/src/rustlang.rs:1742–1772  ·  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

1740/// no closing one (`::<fn() -> u8>`). Mirrors stripRustTurbofish in
1741/// TreeSitterExtractor: both emit the same bytes.
1742fn strip_turbofish(text: &str) -> String {
1743 if !text.contains("::<") {
1744 return text.to_string();
1745 }
1746 let chars: Vec<char> = text.chars().collect();
1747 let mut out = String::with_capacity(text.len());
1748 let mut i = 0;
1749 while i < chars.len() {
1750 if chars[i] == ':' && i + 2 < chars.len() && chars[i + 1] == ':' && chars[i + 2] == '<' {
1751 let mut depth = 0i32;
1752 let mut j = i + 2;
1753 while j < chars.len() {
1754 let c = chars[j];
1755 if c == '<' {
1756 depth += 1;
1757 } else if c == '>' && chars[j - 1] != '-' {
1758 depth -= 1;
1759 if depth == 0 {
1760 break;
1761 }
1762 }
1763 j += 1;
1764 }
1765 i = j + 1;
1766 continue;
1767 }
1768 out.push(chars[i]);
1769 i += 1;
1770 }
1771 out
1772}
1773
1774/// LITERAL_RECEIVER_TYPES (shared table).
1775fn 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