xso{,-proc}: clippy

This doesn't fix all of the clippy warnings in these crates. There are
decisions that needs to be made in there that I'm not willing to make.

Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
pep 2025-11-01 15:36:04 +01:00
commit 00b638fc38
4 changed files with 18 additions and 9 deletions

View file

@ -287,11 +287,11 @@ impl Compound {
// that in version 1.86, but that was rolled back.
let attr_a = attr_a.replace('{', "{{").replace('}', "}}");
let attr_b = attr_b.replace('{', "{{").replace('}', "}}");
let field_a = FieldName(&member_a)
let field_a = FieldName(member_a)
.to_string()
.replace('{', "{{")
.replace('}', "}}");
let field_b = FieldName(&member_b)
let field_b = FieldName(member_b)
.to_string()
.replace('{', "{{")
.replace('}', "}}");

View file

@ -1,4 +1,6 @@
Version NEXT:
* Changes
- Fix some Clippy warnings
Version 0.3.0, release 2025-10-28:
* Changes

View file

@ -408,6 +408,13 @@ pub struct BuilderRegistry<T: ?Sized> {
inner: Mutex<Vec<BuilderRegistryEntry<T>>>,
}
#[cfg(feature = "std")]
impl<T: ?Sized + 'static> Default for BuilderRegistry<T> {
fn default() -> Self {
Self::new()
}
}
#[cfg(feature = "std")]
impl<T: ?Sized + 'static> BuilderRegistry<T> {
/// Create an empty registry.
@ -465,7 +472,7 @@ impl<T: ?Sized + 'static> BuilderRegistry<T> {
}
fn try_build(
inner: &mut Vec<BuilderRegistryEntry<T>>,
inner: &mut [BuilderRegistryEntry<T>],
mut name: rxml::QName,
mut attrs: rxml::AttrMap,
ctx: &Context<'_>,
@ -548,7 +555,7 @@ impl<T: ?Sized + 'static> DynXsoRegistryLookup<T> for BuilderRegistry<T> {
ctx: &Context<'_>,
) -> Result<Box<dyn FromEventsBuilder<Output = Box<T>>>, FromEventsError> {
let mut inner = self.inner.lock().unwrap();
let (name, attrs) = match Self::try_build(&mut *inner, name, attrs, ctx, |qname| {
let (name, attrs) = match Self::try_build(&mut inner, name, attrs, ctx, |qname| {
XmlNameMatcher::Specific(qname.0.as_str(), qname.1.as_str())
}) {
Ok(v) => return Ok(v),
@ -556,7 +563,7 @@ impl<T: ?Sized + 'static> DynXsoRegistryLookup<T> for BuilderRegistry<T> {
Err(FromEventsError::Mismatch { name, attrs }) => (name, attrs),
};
let (name, attrs) = match Self::try_build(&mut *inner, name, attrs, ctx, |qname| {
let (name, attrs) = match Self::try_build(&mut inner, name, attrs, ctx, |qname| {
XmlNameMatcher::InNamespace(qname.0.as_str())
}) {
Ok(v) => return Ok(v),
@ -564,7 +571,7 @@ impl<T: ?Sized + 'static> DynXsoRegistryLookup<T> for BuilderRegistry<T> {
Err(FromEventsError::Mismatch { name, attrs }) => (name, attrs),
};
Self::try_build(&mut *inner, name, attrs, ctx, |_| XmlNameMatcher::Any)
Self::try_build(&mut inner, name, attrs, ctx, |_| XmlNameMatcher::Any)
}
}
@ -1298,7 +1305,7 @@ impl<T: DynXso + ?Sized + 'static> XsoVec<T> {
{
let iter = match self.inner.get(&TypeId::of::<U>()) {
Some(v) => v.deref().iter(),
None => (&[]).iter(),
None => [].iter(),
};
// UNWRAP: We group the values by TypeId, so the downcast should never
// fail, but I am too chicken to use the unchecked variants :).
@ -1335,7 +1342,7 @@ impl<T: DynXso + ?Sized + 'static> XsoVec<T> {
{
let iter = match self.inner.get_mut(&TypeId::of::<U>()) {
Some(v) => v.deref_mut().iter_mut(),
None => (&mut []).iter_mut(),
None => [].iter_mut(),
};
// UNWRAP: We group the values by TypeId, so the downcast should never
// fail, but I am too chicken to use the unchecked variants :).

View file

@ -112,7 +112,7 @@ impl<'x> Context<'x> {
/// Return the `xml:lang` value in effect at the end of the event which
/// is currently being processed.
pub fn language(&self) -> Option<&str> {
self.language.as_deref()
self.language
}
}