MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / env_or_else

Function env_or_else

editor/build.rs:36–41  ·  view source on GitHub ↗

Get an environment variable, or if it is not set or empty, use the provided fallback function. Returns a string with trimmed whitespace.

(key: &str, fallback: impl FnOnce() -> String)

Source from the content-addressed store, hash-verified

34
35/// Get an environment variable, or if it is not set or empty, use the provided fallback function. Returns a string with trimmed whitespace.
36fn env_or_else(key: &str, fallback: impl FnOnce() -> String) -> String {
37 match env::var(key) {
38 Ok(v) if !v.trim().is_empty() => v.trim().to_string(),
39 _ => fallback().trim().to_string(),
40 }
41}
42
43/// Execute a Git command to obtain its output. Return "unknown" if it fails for any of the possible reasons.
44fn git_or_unknown(args: &[&str]) -> String {

Callers 1

mainFunction · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected