MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_str

Method from_str

atomic-core/src/diff/algorithm.rs:131–137  ·  view source on GitHub ↗

Parse an algorithm name from a string. # Accepted Values - "myers" or "Myers" → `Algorithm::Myers` - "patience" or "Patience" → `Algorithm::Patience` # Errors Returns `AlgorithmParseError` if the string doesn't match any known algorithm name.

(s: &str)

Source from the content-addressed store, hash-verified

129 /// Returns `AlgorithmParseError` if the string doesn't match
130 /// any known algorithm name.
131 fn from_str(s: &str) -> Result<Self, Self::Err> {
132 match s.to_lowercase().as_str() {
133 "myers" => Ok(Algorithm::Myers),
134 "patience" => Ok(Algorithm::Patience),
135 _ => Err(AlgorithmParseError(s.to_string())),
136 }
137 }
138}
139
140/// Error returned when parsing an unknown algorithm name.

Callers

nothing calls this directly

Calls 2

AlgorithmParseErrorClass · 0.85
as_strMethod · 0.45

Tested by

no test coverage detected