MCPcopy Create free account
hub / github.com/apache/fory / extract_generic_inner

Function extract_generic_inner

rust/fory-derive/src/object/util.rs:212–222  ·  view source on GitHub ↗

Extract the inner generic arguments from a type name while ignoring path qualifiers. e.g., both `Vec ` and `::std::vec::Vec ` return `T` when `outer` is `Vec`.

(s: &'a str, outer: &str)

Source from the content-addressed store, hash-verified

210///
211/// e.g., both `Vec<T>` and `::std::vec::Vec<T>` return `T` when `outer` is `Vec`.
212fn extract_generic_inner<'a>(s: &'a str, outer: &str) -> Option<&'a str> {
213 let generic_start = s.find('<')?;
214 let owner = s[..generic_start]
215 .rsplit("::")
216 .next()
217 .unwrap_or(&s[..generic_start]);
218 if owner != outer {
219 return None;
220 }
221 s[generic_start + 1..].strip_suffix('>')
222}
223
224/// Return the final path segment so absolute generated paths match the same runtime type names.
225///

Callers 3

extract_option_innerFunction · 0.85
get_type_id_by_nameFunction · 0.85

Calls 3

findMethod · 0.80
rsplitMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected