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

Function strip_turbofish

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

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