MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / normalize_protocols

Function normalize_protocols

crates/openshell-core/src/inference.rs:311–326  ·  view source on GitHub ↗

Normalize a list of protocol strings: trim, lowercase, deduplicate, skip empty.

(protocols: &[String])

Source from the content-addressed store, hash-verified

309
310/// Normalize a list of protocol strings: trim, lowercase, deduplicate, skip empty.
311pub fn normalize_protocols(protocols: &[String]) -> Vec<String> {
312 let mut normalized = Vec::new();
313 let mut seen = HashSet::new();
314
315 for protocol in protocols {
316 let candidate = protocol.trim().to_ascii_lowercase();
317 if candidate.is_empty() {
318 continue;
319 }
320 if seen.insert(candidate.clone()) {
321 normalized.push(candidate);
322 }
323 }
324
325 normalized
326}
327
328#[cfg(test)]
329mod tests {

Callers 4

resolveMethod · 0.85
empty_inputFunction · 0.85

Calls 2

pushMethod · 0.80
is_emptyMethod · 0.45

Tested by 3

empty_inputFunction · 0.68