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

Function truncate_for_display

crates/openshell-policy/src/lib.rs:1326–1332  ·  view source on GitHub ↗

Truncate a string for safe inclusion in error messages.

(s: &str)

Source from the content-addressed store, hash-verified

1324
1325/// Truncate a string for safe inclusion in error messages.
1326fn truncate_for_display(s: &str) -> String {
1327 if s.len() <= 80 {
1328 s.to_string()
1329 } else {
1330 format!("{}...", &s[..77])
1331 }
1332}
1333
1334/// Normalize a filesystem path by collapsing redundant separators
1335/// and removing trailing slashes, without requiring the path to exist on disk.

Callers 1

validate_sandbox_policyFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected