MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / _indent

Function _indent

cranelift/srcgen/src/lib.rs:253–260  ·  view source on GitHub ↗

Compute the indentation of s, or None of an empty line.

(s: &str)

Source from the content-addressed store, hash-verified

251
252/// Compute the indentation of s, or None of an empty line.
253fn _indent(s: &str) -> Option<usize> {
254 if s.is_empty() {
255 None
256 } else {
257 let t = s.trim_start();
258 Some(s.len() - t.len())
259 }
260}
261
262/// Given a multi-line string, split it into a sequence of lines after
263/// stripping a common indentation. This is useful for strings defined with

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected