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

Function strip_turbofish

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

1766/// no closing one (`::<fn() -> u8>`). Mirrors stripRustTurbofish in
1767/// TreeSitterExtractor: both emit the same bytes.
1768fn strip_turbofish(text: &str) -> String {
1769 if !text.contains("::<") {
1770 return text.to_string();
1771 }
1772 let chars: Vec<char> = text.chars().collect();
1773 let mut out = String::with_capacity(text.len());
1774 let mut i = 0;
1775 while i < chars.len() {
1776 if chars[i] == ':' && i + 2 < chars.len() && chars[i + 1] == ':' && chars[i + 2] == '<' {
1777 let mut depth = 0i32;
1778 let mut j = i + 2;
1779 while j < chars.len() {
1780 let c = chars[j];
1781 if c == '<' {
1782 depth += 1;
1783 } else if c == '>' && chars[j - 1] != '-' {
1784 depth -= 1;
1785 if depth == 0 {
1786 break;
1787 }
1788 }
1789 j += 1;
1790 }
1791 i = j + 1;
1792 continue;
1793 }
1794 out.push(chars[i]);
1795 i += 1;
1796 }
1797 out
1798}
1799
1800/// LITERAL_RECEIVER_TYPES (shared table).
1801fn 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