Very similar to `string()`, but as path, whose query can never fail.
Showing the changes to git-config/src (1 of 2 files). Show all
Unified · Split
| @@ -466,6 +466,20 @@ impl<'event> GitConfig<'event> { · 465 unmodified lines | |||
| 466 | .map(|v| values::String::from(v).value) | 466 | .map(|v| values::String::from(v).value) |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | /// Like [`value()`][GitConfig::value()], but returning an `Option` if the paty wasn't found. | ||
| 470 | /// | ||
| 471 | /// As strings perform no conversions, this will never fail. | ||
| 472 | pub fn path( | ||
| 473 | &'event self, | ||
| 474 | section_name: &str, | ||
| 475 | subsection_name: Option<&str>, | ||
| 476 | key: &str, | ||
| 477 | ) -> Option<values::Path<'event>> { | ||
| 478 | self.raw_value(section_name, subsection_name, key) | ||
| 479 | .ok() | ||
| 480 | .map(|v| values::Path::from(v)) | ||
| 481 | } | ||
| 482 | |||
| 469 | /// Like [`value()`][GitConfig::value()], but returning an `Option` if the boolean wasn't found. | 483 | /// Like [`value()`][GitConfig::value()], but returning an `Option` if the boolean wasn't found. |
| 470 | pub fn boolean( | 484 | pub fn boolean( |
| 471 | &'event self, | 485 | &'event self, |