History

unclutter lifetime declarations (#331)

Only use what we actually need.

Sebastian Thiel committed 4 years ago

Commit e571fdb1 parent 183c7ae5 files · +57 −57Browse files

Unified · Split

5 files
  1. git-config/src/file/access/low_level/mutating.rs +22 −22
  2. git-config/src/file/access/low_level/read_only.rs +6 −6
  3. git-config/src/file/access/raw.rs +16 −16
  4. git-config/src/file/utils.rs +5 −5
  5. git-config/src/fs.rs +8 −8
git-config/src/file/access/low_level/mutating.rs+22−22
@@ -9,13 +9,13 @@ use crate::{ · 8 unmodified lines
99 };
1010
1111 /// Mutating low-level access methods.
12−impl<'a> File<'a> {
12+impl<'event> File<'event> {
1313 /// 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> {
1919 let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?;
2020 let id = section_ids.last().expect("BUG: Section lookup vec was empty");
2121 Ok(MutableSection::new(
@@ -56,9 +56,9 @@ impl<'a> File<'a> { · 34 unmodified lines
5656 /// ```
5757 pub fn new_section(
5858 &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> {
6262 let mut section = self.push_section(section_name, subsection_name, SectionBody::default());
6363 section.push_newline();
6464 section
@@ -99,11 +99,11 @@ impl<'a> File<'a> { · 34 unmodified lines
9999 /// let events = git_config.remove_section("hello", Some("world".into()));
100100 /// assert_eq!(git_config.to_string(), "[hello \"world\"]\n some-value = 4\n");
101101 /// ```
102− pub fn remove_section<'lookup>(
102+ pub fn remove_section<'a>(
103103 &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>> {
107107 let id = self
108108 .section_ids_by_name_and_subname(section_name, subsection_name.into())
109109 .ok()?
@@ -121,10 +121,10 @@ impl<'a> File<'a> { · 11 unmodified lines
121121 /// to it.
122122 pub fn push_section(
123123 &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> {
128128 let subsection_name = subsection_name.into().map(into_cow_bstr);
129129 self.push_section_internal(
130130 section::Header {
@@ -137,12 +137,12 @@ impl<'a> File<'a> { · 6 unmodified lines
137137 }
138138
139139 /// Renames a section, modifying the last matching section.
140− pub fn rename_section<'lookup>(
140+ pub fn rename_section<'a>(
141141 &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>>>,
146146 ) -> Result<(), lookup::existing::Error> {
147147 let id = self.section_ids_by_name_and_subname(section_name, subsection_name.into())?;
148148 let id = id
git-config/src/file/access/low_level/read_only.rs+6−6
@@ -114,10 +114,10 @@ impl<'event> File<'event> { · 113 unmodified lines
114114 }
115115
116116 /// Returns an immutable section reference.
117− pub fn section<'lookup>(
117+ pub fn section(
118118 &mut self,
119− section_name: &'lookup str,
120− subsection_name: Option<&'lookup str>,
119+ section_name: &str,
120+ subsection_name: Option<&str>,
121121 ) -> Result<&SectionBody<'event>, lookup::existing::Error> {
122122 let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?;
123123 let id = section_ids.last().expect("BUG: Section lookup vec was empty");
@@ -158,7 +158,7 @@ impl<'event> File<'event> { · 34 unmodified lines
158158 /// assert_eq!(git_config.sections_by_name("core").len(), 3);
159159 /// ```
160160 #[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>> {
162162 self.section_ids_by_name(section_name)
163163 .unwrap_or_default()
164164 .into_iter()
@@ -216,9 +216,9 @@ impl<'event> File<'event> { · 51 unmodified lines
216216 /// }
217217 /// }
218218 /// ```
219− pub fn sections_by_name_with_header<'lookup>(
219+ pub fn sections_by_name_with_header(
220220 &self,
221− section_name: &'lookup str,
221+ section_name: &str,
222222 ) -> Vec<(&section::Header<'event>, &SectionBody<'event>)> {
223223 self.section_ids_by_name(section_name)
224224 .unwrap_or_default()
git-config/src/file/access/raw.rs+16−16
@@ -12,17 +12,17 @@ use crate::{ · 11 unmodified lines
1212 ///
1313 /// These functions are the raw value API. Instead of returning Rust structures,
1414 /// these functions return bytes which may or may not be owned.
15−impl<'a> File<'a> {
15+impl<'event> File<'event> {
1616 /// Returns an uninterpreted value given a section, an optional subsection
1717 /// and key.
1818 ///
1919 /// Consider [`Self::raw_multi_value`] if you want to get all values of
2020 /// a multivar instead.
21− pub fn raw_value<'lookup>(
21+ pub fn raw_value(
2222 &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,
2626 ) -> Result<Cow<'_, BStr>, lookup::existing::Error> {
2727 // Note: cannot wrap around the raw_multi_value method because we need
2828 // to guarantee that the highest section id is used (so that we follow
@@ -56,7 +56,7 @@ impl<'a> File<'a> { · 27 unmodified lines
5656 section_name: &'lookup str,
5757 subsection_name: Option<&'lookup str>,
5858 key: &'lookup str,
59− ) -> Result<MutableValue<'_, 'lookup, 'a>, lookup::existing::Error> {
59+ ) -> Result<MutableValue<'_, 'lookup, 'event>, lookup::existing::Error> {
6060 let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?;
6161 let key = section::Key(Cow::<BStr>::Borrowed(key.into()));
6262
@@ -222,7 +222,7 @@ impl<'a> File<'a> { · 159 unmodified lines
222222 section_name: &'lookup str,
223223 subsection_name: Option<&'lookup str>,
224224 key: &'lookup str,
225− ) -> Result<MutableMultiValue<'_, 'lookup, 'a>, lookup::existing::Error> {
225+ ) -> Result<MutableMultiValue<'_, 'lookup, 'event>, lookup::existing::Error> {
226226 let section_ids = self.section_ids_by_name_and_subname(section_name, subsection_name)?;
227227 let key = section::Key(Cow::<BStr>::Borrowed(key.into()));
228228
@@ -296,11 +296,11 @@ impl<'a> File<'a> { · 67 unmodified lines
296296 /// assert_eq!(git_config.raw_value("core", None, "a")?, Cow::<BStr>::Borrowed("e".into()));
297297 /// # Ok::<(), Box<dyn std::error::Error>>(())
298298 /// ```
299− pub fn set_raw_value<'lookup>(
299+ pub fn set_raw_value(
300300 &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,
304304 new_value: BString,
305305 ) -> Result<(), lookup::existing::Error> {
306306 self.raw_value_mut(section_name, subsection_name, key)
@@ -393,12 +393,12 @@ impl<'a> File<'a> { · 86 unmodified lines
393393 /// ```
394394 ///
395395 /// [`raw_multi_value_mut`]: Self::raw_multi_value_mut
396− pub fn set_raw_multi_value<'lookup>(
396+ pub fn set_raw_multi_value(
397397 &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>>,
402402 ) -> Result<(), lookup::existing::Error> {
403403 self.raw_multi_value_mut(section_name, subsection_name, key)
404404 .map(|mut v| v.set_values(new_values))
git-config/src/file/utils.rs+5−5
@@ -57,10 +57,10 @@ impl<'event> File<'event> { · 56 unmodified lines
5757 }
5858
5959 /// 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>(
6161 &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>,
6464 ) -> Result<Vec<SectionId>, lookup::existing::Error> {
6565 let section_name = section_name.into();
6666 let section_ids = self
@@ -92,9 +92,9 @@ impl<'event> File<'event> { · 25 unmodified lines
9292 .ok_or(lookup::existing::Error::SubSectionMissing)
9393 }
9494
95− pub(crate) fn section_ids_by_name<'lookup>(
95+ pub(crate) fn section_ids_by_name<'a>(
9696 &self,
97− section_name: impl Into<section::Name<'lookup>>,
97+ section_name: impl Into<section::Name<'a>>,
9898 ) -> Result<Vec<SectionId>, lookup::existing::Error> {
9999 let section_name = section_name.into();
100100 self.section_lookup_tree
git-config/src/fs.rs+8−8
@@ -179,11 +179,11 @@ impl<'a> Config<'a> { · 178 unmodified lines
179179 None
180180 }
181181
182− pub fn try_value<'lookup, T: TryFrom<Cow<'a, BStr>>>(
182+ pub fn try_value<T: TryFrom<Cow<'a, BStr>>>(
183183 &'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,
187187 ) -> Result<Option<T>, lookup::Error<T::Error>> {
188188 self.try_value_with_source(section_name, subsection_name, key)
189189 .map(|res| res.map(|(value, _)| value))
@@ -193,11 +193,11 @@ impl<'a> Config<'a> { · 3 unmodified lines
193193 /// if the key was not found. On a successful parse, the value will be
194194 /// returned as well as the source location. This respects the priority of
195195 /// 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>>>(
197197 &'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,
201201 ) -> Result<Option<(T, ConfigSource)>, lookup::Error<T::Error>> {
202202 let mapping = self.mapping();
203203

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t