From c23a457e72abe608715ac76f076f47dc42af07a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:44 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/gix-config/src/file/mutable/mod.rs | 6 +++--- vendor/gix-config/src/file/mutable/section.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'vendor/gix-config/src/file/mutable') diff --git a/vendor/gix-config/src/file/mutable/mod.rs b/vendor/gix-config/src/file/mutable/mod.rs index ad99e09b9..506a5484d 100644 --- a/vendor/gix-config/src/file/mutable/mod.rs +++ b/vendor/gix-config/src/file/mutable/mod.rs @@ -9,10 +9,10 @@ pub(crate) mod section; pub(crate) mod value; fn escape_value(value: &BStr) -> BString { - let starts_with_whitespace = value.first().map_or(false, |b| b.is_ascii_whitespace()); + let starts_with_whitespace = value.first().map_or(false, u8::is_ascii_whitespace); let ends_with_whitespace = value .get(value.len().saturating_sub(1)) - .map_or(false, |b| b.is_ascii_whitespace()); + .map_or(false, u8::is_ascii_whitespace); let contains_comment_indicators = value.find_byteset(b";#").is_some(); let quote = starts_with_whitespace || ends_with_whitespace || contains_comment_indicators; @@ -74,7 +74,7 @@ impl<'a> Whitespace<'a> { .find_map(|(idx, e)| matches!(e, Event::SectionKey(_)).then(|| idx)); key_pos .map(|key_pos| { - let pre_key = s.0[..key_pos].iter().rev().next().and_then(|e| match e { + let pre_key = s.0[..key_pos].iter().next_back().and_then(|e| match e { Event::Whitespace(s) => Some(s.clone()), _ => None, }); diff --git a/vendor/gix-config/src/file/mutable/section.rs b/vendor/gix-config/src/file/mutable/section.rs index def68ac60..336ccad2d 100644 --- a/vendor/gix-config/src/file/mutable/section.rs +++ b/vendor/gix-config/src/file/mutable/section.rs @@ -123,10 +123,10 @@ impl<'a, 'event> SectionMut<'a, 'event> { /// Sets the last key value pair if it exists, or adds the new value. /// Returns the previous value if it replaced a value, or None if it adds /// the value. - pub fn set<'b>(&mut self, key: Key<'event>, value: impl Into<&'b BStr>) -> Option> { + pub fn set(&mut self, key: Key<'event>, value: &BStr) -> Option> { match self.key_and_value_range_by(&key) { None => { - self.push(key, Some(value.into())); + self.push(key, Some(value)); None } Some((key_range, value_range)) => { @@ -136,15 +136,15 @@ impl<'a, 'event> SectionMut<'a, 'event> { self.section .body .0 - .insert(range_start, Event::Value(escape_value(value.into()).into())); + .insert(range_start, Event::Value(escape_value(value).into())); Some(ret) } } } /// Removes the latest value by key and returns it, if it exists. - pub fn remove(&mut self, key: impl AsRef) -> Option> { - let key = Key::from_str_unchecked(key.as_ref()); + pub fn remove(&mut self, key: &str) -> Option> { + let key = Key::from_str_unchecked(key); let (key_range, _value_range) = self.key_and_value_range_by(&key)?; Some(self.remove_internal(key_range, true)) } @@ -185,7 +185,7 @@ impl<'a, 'event> SectionMut<'a, 'event> { assert!( whitespace .as_deref() - .map_or(true, |ws| ws.iter().all(|b| b.is_ascii_whitespace())), + .map_or(true, |ws| ws.iter().all(u8::is_ascii_whitespace)), "input whitespace must only contain whitespace characters." ); self.whitespace.pre_key = whitespace; -- cgit v1.2.3