Parse a diff format from string. # Accepted Values - "unified" → `DiffFormat::Unified` - "stat" → `DiffFormat::Stat` - "name-only", "nameonly" → `DiffFormat::NameOnly` - "name-status", "namestatus" → `DiffFormat::NameStatus` # Errors Returns an error string if the format is not recognized.
(s: &str)
| 80 | /// |
| 81 | /// Returns an error string if the format is not recognized. |
| 82 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 83 | match s.to_lowercase().as_str() { |
| 84 | "unified" | "u" => Ok(DiffFormat::Unified), |
| 85 | "stat" | "s" => Ok(DiffFormat::Stat), |
| 86 | "name-only" | "nameonly" | "names" => Ok(DiffFormat::NameOnly), |
| 87 | "name-status" | "namestatus" | "status" => Ok(DiffFormat::NameStatus), |
| 88 | _ => Err(format!( |
| 89 | "unknown diff format '{}'. Valid options: unified, stat, name-only, name-status", |
| 90 | s |
| 91 | )), |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // Diff Statistics |