Only use what we actually need.
Unified · Split
| @@ -9,13 +9,13 @@ use crate::{ · 8 unmodified lines | ||
| 9 | 9 | }; |
| 10 | 10 | |
| 11 | 11 | /// Mutating low-level access methods. |
| 12 | −impl<'a> File<'a> { | |
| 12 | +impl<'event> File<'event> { | |
| 13 | 13 | /// Returns an mutable section reference. |
| 14 | − pub fn section_mut<'lookup>( | |
| 15 | − &mut self, | |
| 16 | − section_name: &'lookup str, | |
| 17 | − subsection_name: Option<&'lookup str>, | |
| 18 | − ) -> Result<MutableSection<'_, 'a>, lookup::existing::Error> { | |
| 14 | + pub fn section_mut<'a>( | |
| 15 | + &'a mut self, | |
| 16 | + section_name: &str, | |
| 17 | + subsection_name: Option<&str>, | |
| 18 | + ) -> Result<MutableSection<'a, 'event>, lookup::existing::Error> { | |
| 19 | 19 | let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?; |
| 20 | 20 | let id = section_ids.last().expect("BUG: Section lookup vec was empty"); |
| 21 | 21 | Ok(MutableSection::new( |
| @@ -56,9 +56,9 @@ impl<'a> File<'a> { · 34 unmodified lines | ||
| 56 | 56 | /// ``` |
| 57 | 57 | pub fn new_section( |
| 58 | 58 | &mut self, |
| 59 | − section_name: impl Into<Cow<'a, str>>, | |
| 60 | − subsection_name: impl Into<Option<Cow<'a, str>>>, | |
| 61 | − ) -> MutableSection<'_, 'a> { | |
| 59 | + section_name: impl Into<Cow<'event, str>>, | |
| 60 | + subsection_name: impl Into<Option<Cow<'event, str>>>, | |
| 61 | + ) -> MutableSection<'_, 'event> { | |
| 62 | 62 | let mut section = self.push_section(section_name, subsection_name, SectionBody::default()); |
| 63 | 63 | section.push_newline(); |
| 64 | 64 | section |
| @@ -99,11 +99,11 @@ impl<'a> File<'a> { · 34 unmodified lines | ||
| 99 | 99 | /// let events = git_config.remove_section("hello", Some("world".into())); |
| 100 | 100 | /// assert_eq!(git_config.to_string(), "[hello \"world\"]\n some-value = 4\n"); |
| 101 | 101 | /// ``` |
| 102 | − pub fn remove_section<'lookup>( | |
| 102 | + pub fn remove_section<'a>( | |
| 103 | 103 | &mut self, |
| 104 | − section_name: &'lookup str, | |
| 105 | − subsection_name: impl Into<Option<&'lookup str>>, | |
| 106 | − ) -> Option<SectionBody<'a>> { | |
| 104 | + section_name: &str, | |
| 105 | + subsection_name: impl Into<Option<&'a str>>, | |
| 106 | + ) -> Option<SectionBody<'event>> { | |
| 107 | 107 | let id = self |
| 108 | 108 | .section_ids_by_name_and_subname(section_name, subsection_name.into()) |
| 109 | 109 | .ok()? |
| @@ -121,10 +121,10 @@ impl<'a> File<'a> { · 11 unmodified lines | ||
| 121 | 121 | /// to it. |
| 122 | 122 | pub fn push_section( |
| 123 | 123 | &mut self, |
| 124 | − section_name: impl Into<Cow<'a, str>>, | |
| 125 | − subsection_name: impl Into<Option<Cow<'a, str>>>, | |
| 126 | − section: SectionBody<'a>, | |
| 127 | − ) -> MutableSection<'_, 'a> { | |
| 124 | + section_name: impl Into<Cow<'event, str>>, | |
| 125 | + subsection_name: impl Into<Option<Cow<'event, str>>>, | |
| 126 | + section: SectionBody<'event>, | |
| 127 | + ) -> MutableSection<'_, 'event> { | |
| 128 | 128 | let subsection_name = subsection_name.into().map(into_cow_bstr); |
| 129 | 129 | self.push_section_internal( |
| 130 | 130 | section::Header { |
| @@ -137,12 +137,12 @@ impl<'a> File<'a> { · 6 unmodified lines | ||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /// Renames a section, modifying the last matching section. |
| 140 | − pub fn rename_section<'lookup>( | |
| 140 | + pub fn rename_section<'a>( | |
| 141 | 141 | &mut self, |
| 142 | − section_name: &'lookup str, | |
| 143 | − subsection_name: impl Into<Option<&'lookup str>>, | |
| 144 | − new_section_name: impl Into<section::Name<'a>>, | |
| 145 | − new_subsection_name: impl Into<Option<Cow<'a, str>>>, | |
| 142 | + section_name: &str, | |
| 143 | + subsection_name: impl Into<Option<&'a str>>, | |
| 144 | + new_section_name: impl Into<section::Name<'event>>, | |
| 145 | + new_subsection_name: impl Into<Option<Cow<'event, str>>>, | |
| 146 | 146 | ) -> Result<(), lookup::existing::Error> { |
| 147 | 147 | let id = self.section_ids_by_name_and_subname(section_name, subsection_name.into())?; |
| 148 | 148 | let id = id |
| @@ -114,10 +114,10 @@ impl<'event> File<'event> { · 113 unmodified lines | ||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /// Returns an immutable section reference. |
| 117 | − pub fn section<'lookup>( | |
| 117 | + pub fn section( | |
| 118 | 118 | &mut self, |
| 119 | − section_name: &'lookup str, | |
| 120 | − subsection_name: Option<&'lookup str>, | |
| 119 | + section_name: &str, | |
| 120 | + subsection_name: Option<&str>, | |
| 121 | 121 | ) -> Result<&SectionBody<'event>, lookup::existing::Error> { |
| 122 | 122 | let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?; |
| 123 | 123 | let id = section_ids.last().expect("BUG: Section lookup vec was empty"); |
| @@ -158,7 +158,7 @@ impl<'event> File<'event> { · 34 unmodified lines | ||
| 158 | 158 | /// assert_eq!(git_config.sections_by_name("core").len(), 3); |
| 159 | 159 | /// ``` |
| 160 | 160 | #[must_use] |
| 161 | − pub fn sections_by_name<'lookup>(&self, section_name: &'lookup str) -> Vec<&SectionBody<'event>> { | |
| 161 | + pub fn sections_by_name(&self, section_name: &str) -> Vec<&SectionBody<'event>> { | |
| 162 | 162 | self.section_ids_by_name(section_name) |
| 163 | 163 | .unwrap_or_default() |
| 164 | 164 | .into_iter() |
| @@ -216,9 +216,9 @@ impl<'event> File<'event> { · 51 unmodified lines | ||
| 216 | 216 | /// } |
| 217 | 217 | /// } |
| 218 | 218 | /// ``` |
| 219 | − pub fn sections_by_name_with_header<'lookup>( | |
| 219 | + pub fn sections_by_name_with_header( | |
| 220 | 220 | &self, |
| 221 | − section_name: &'lookup str, | |
| 221 | + section_name: &str, | |
| 222 | 222 | ) -> Vec<(§ion::Header<'event>, &SectionBody<'event>)> { |
| 223 | 223 | self.section_ids_by_name(section_name) |
| 224 | 224 | .unwrap_or_default() |
| @@ -12,17 +12,17 @@ use crate::{ · 11 unmodified lines | ||
| 12 | 12 | /// |
| 13 | 13 | /// These functions are the raw value API. Instead of returning Rust structures, |
| 14 | 14 | /// these functions return bytes which may or may not be owned. |
| 15 | −impl<'a> File<'a> { | |
| 15 | +impl<'event> File<'event> { | |
| 16 | 16 | /// Returns an uninterpreted value given a section, an optional subsection |
| 17 | 17 | /// and key. |
| 18 | 18 | /// |
| 19 | 19 | /// Consider [`Self::raw_multi_value`] if you want to get all values of |
| 20 | 20 | /// a multivar instead. |
| 21 | − pub fn raw_value<'lookup>( | |
| 21 | + pub fn raw_value( | |
| 22 | 22 | &self, |
| 23 | − section_name: &'lookup str, | |
| 24 | − subsection_name: Option<&'lookup str>, | |
| 25 | − key: &'lookup str, | |
| 23 | + section_name: &str, | |
| 24 | + subsection_name: Option<&str>, | |
| 25 | + key: &str, | |
| 26 | 26 | ) -> Result<Cow<'_, BStr>, lookup::existing::Error> { |
| 27 | 27 | // Note: cannot wrap around the raw_multi_value method because we need |
| 28 | 28 | // to guarantee that the highest section id is used (so that we follow |
| @@ -56,7 +56,7 @@ impl<'a> File<'a> { · 27 unmodified lines | ||
| 56 | 56 | section_name: &'lookup str, |
| 57 | 57 | subsection_name: Option<&'lookup str>, |
| 58 | 58 | key: &'lookup str, |
| 59 | − ) -> Result<MutableValue<'_, 'lookup, 'a>, lookup::existing::Error> { | |
| 59 | + ) -> Result<MutableValue<'_, 'lookup, 'event>, lookup::existing::Error> { | |
| 60 | 60 | let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?; |
| 61 | 61 | let key = section::Key(Cow::<BStr>::Borrowed(key.into())); |
| 62 | 62 | |
| @@ -222,7 +222,7 @@ impl<'a> File<'a> { · 159 unmodified lines | ||
| 222 | 222 | section_name: &'lookup str, |
| 223 | 223 | subsection_name: Option<&'lookup str>, |
| 224 | 224 | key: &'lookup str, |
| 225 | − ) -> Result<MutableMultiValue<'_, 'lookup, 'a>, lookup::existing::Error> { | |
| 225 | + ) -> Result<MutableMultiValue<'_, 'lookup, 'event>, lookup::existing::Error> { | |
| 226 | 226 | let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?; |
| 227 | 227 | let key = section::Key(Cow::<BStr>::Borrowed(key.into())); |
| 228 | 228 | |
| @@ -296,11 +296,11 @@ impl<'a> File<'a> { · 67 unmodified lines | ||
| 296 | 296 | /// assert_eq!(git_config.raw_value("core", None, "a")?, Cow::<BStr>::Borrowed("e".into())); |
| 297 | 297 | /// # Ok::<(), Box<dyn std::error::Error>>(()) |
| 298 | 298 | /// ``` |
| 299 | − pub fn set_raw_value<'lookup>( | |
| 299 | + pub fn set_raw_value( | |
| 300 | 300 | &mut self, |
| 301 | − section_name: &'lookup str, | |
| 302 | − subsection_name: Option<&'lookup str>, | |
| 303 | − key: &'lookup str, | |
| 301 | + section_name: &str, | |
| 302 | + subsection_name: Option<&str>, | |
| 303 | + key: &str, | |
| 304 | 304 | new_value: BString, |
| 305 | 305 | ) -> Result<(), lookup::existing::Error> { |
| 306 | 306 | self.raw_value_mut(section_name, subsection_name, key) |
| @@ -393,12 +393,12 @@ impl<'a> File<'a> { · 86 unmodified lines | ||
| 393 | 393 | /// ``` |
| 394 | 394 | /// |
| 395 | 395 | /// [`raw_multi_value_mut`]: Self::raw_multi_value_mut |
| 396 | − pub fn set_raw_multi_value<'lookup>( | |
| 396 | + pub fn set_raw_multi_value( | |
| 397 | 397 | &mut self, |
| 398 | − section_name: &'lookup str, | |
| 399 | − subsection_name: Option<&'lookup str>, | |
| 400 | − key: &'lookup str, | |
| 401 | − new_values: impl Iterator<Item = Cow<'a, BStr>>, | |
| 398 | + section_name: &str, | |
| 399 | + subsection_name: Option<&str>, | |
| 400 | + key: &str, | |
| 401 | + new_values: impl Iterator<Item = Cow<'event, BStr>>, | |
| 402 | 402 | ) -> Result<(), lookup::existing::Error> { |
| 403 | 403 | self.raw_multi_value_mut(section_name, subsection_name, key) |
| 404 | 404 | .map(|mut v| v.set_values(new_values)) |
| @@ -57,10 +57,10 @@ impl<'event> File<'event> { · 56 unmodified lines | ||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /// Returns the mapping between section and subsection name to section ids. |
| 60 | − pub(crate) fn section_ids_by_name_and_subname<'lookup>( | |
| 60 | + pub(crate) fn section_ids_by_name_and_subname<'a>( | |
| 61 | 61 | &self, |
| 62 | − section_name: impl Into<section::Name<'lookup>>, | |
| 63 | − subsection_name: Option<&'lookup str>, | |
| 62 | + section_name: impl Into<section::Name<'a>>, | |
| 63 | + subsection_name: Option<&str>, | |
| 64 | 64 | ) -> Result<Vec<SectionId>, lookup::existing::Error> { |
| 65 | 65 | let section_name = section_name.into(); |
| 66 | 66 | let section_ids = self |
| @@ -92,9 +92,9 @@ impl<'event> File<'event> { · 25 unmodified lines | ||
| 92 | 92 | .ok_or(lookup::existing::Error::SubSectionMissing) |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | − pub(crate) fn section_ids_by_name<'lookup>( | |
| 95 | + pub(crate) fn section_ids_by_name<'a>( | |
| 96 | 96 | &self, |
| 97 | − section_name: impl Into<section::Name<'lookup>>, | |
| 97 | + section_name: impl Into<section::Name<'a>>, | |
| 98 | 98 | ) -> Result<Vec<SectionId>, lookup::existing::Error> { |
| 99 | 99 | let section_name = section_name.into(); |
| 100 | 100 | self.section_lookup_tree |
| @@ -179,11 +179,11 @@ impl<'a> Config<'a> { · 178 unmodified lines | ||
| 179 | 179 | None |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | − pub fn try_value<'lookup, T: TryFrom<Cow<'a, BStr>>>( | |
| 182 | + pub fn try_value<T: TryFrom<Cow<'a, BStr>>>( | |
| 183 | 183 | &'a self, |
| 184 | − section_name: &'lookup str, | |
| 185 | − subsection_name: Option<&'lookup str>, | |
| 186 | − key: &'lookup str, | |
| 184 | + section_name: &str, | |
| 185 | + subsection_name: Option<&str>, | |
| 186 | + key: &str, | |
| 187 | 187 | ) -> Result<Option<T>, lookup::Error<T::Error>> { |
| 188 | 188 | self.try_value_with_source(section_name, subsection_name, key) |
| 189 | 189 | .map(|res| res.map(|(value, _)| value)) |
| @@ -193,11 +193,11 @@ impl<'a> Config<'a> { · 3 unmodified lines | ||
| 193 | 193 | /// if the key was not found. On a successful parse, the value will be |
| 194 | 194 | /// returned as well as the source location. This respects the priority of |
| 195 | 195 | /// the various configuration files. |
| 196 | − pub fn try_value_with_source<'lookup, T: TryFrom<Cow<'a, BStr>>>( | |
| 196 | + pub fn try_value_with_source<T: TryFrom<Cow<'a, BStr>>>( | |
| 197 | 197 | &'a self, |
| 198 | − section_name: &'lookup str, | |
| 199 | − subsection_name: Option<&'lookup str>, | |
| 200 | − key: &'lookup str, | |
| 198 | + section_name: &str, | |
| 199 | + subsection_name: Option<&str>, | |
| 200 | + key: &str, | |
| 201 | 201 | ) -> Result<Option<(T, ConfigSource)>, lookup::Error<T::Error>> { |
| 202 | 202 | let mapping = self.mapping(); |
| 203 | 203 | |