Skip to content

Commit

Permalink
apply new lints from Rust 1.74
Browse files Browse the repository at this point in the history
  • Loading branch information
pchampin committed Dec 4, 2023
1 parent 1ab31b0 commit 719f7eb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 24 deletions.
15 changes: 7 additions & 8 deletions api/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ mod check_implementability {
Box::new(
self.triples
.iter()
.filter_map(|t| t.asserted.then(|| Ok(self.make_triple(t.spo)))),
.filter(|t| t.asserted)
.map(|t| Ok(self.make_triple(t.spo))),
)
}
}
Expand Down Expand Up @@ -704,13 +705,11 @@ mod check_implementability_lazy_term {
type Error = std::convert::Infallible;

fn triples(&self) -> GTripleSource<Self> {
Box::new(self.triples.iter().filter_map(|t| {
t.asserted.then(|| {
Ok(t.spo.map(|i| MyTerm {
graph: self,
index: i,
}))
})
Box::new(self.triples.iter().filter(|t| t.asserted).map(|t| {
Ok(t.spo.map(|i| MyTerm {
graph: self,
index: i,
}))
}))
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/term/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! [`GraphNameMatcher`'s implementors lists](GraphNameMatcher#foreign-impls).
//!
//! For methods using matchers (with examples), see for example
//! [`Triple::matched_by`](crate::triple::Triple::matched_by),
//! [`Triple::matched_by`],
//! [`Graph::triples_matching`](crate::graph::Graph::triples_matching),
//! [`MutableGraph::remove_matching`](crate::graph::MutableGraph::remove_matching),
//! [`MutableGraph::retain_matching`](crate::graph::MutableGraph::retain_matching),
Expand Down
2 changes: 1 addition & 1 deletion iri/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! This module is based on <https://docs.rs/oxiri/>.
//!
//! NB: compared to [`Iri`](crate::Iri) and [`IriRef`](crate::IriRef),
//! NB: compared to [`Iri`] and [`IriRef`],
//! [`BaseIri`] and [`BaseIriRef`] are slower to build,
//! because they analyse the internal structure of the IRI,
//! in order to allow for efficient resolution of relative IRIs.
Expand Down
4 changes: 2 additions & 2 deletions resource/src/loader/_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait Loader: Sync + Sized {
let bufread = io::BufReader::new(&data[..]);
match &ctype[..] {
"text/turtle" => turtle::TurtleParser {
base: Some(iri.as_ref().map_unchecked(|t| t.borrow().to_string())),
base: Some(iri.as_ref().map_unchecked(|t| t.to_string())),
}
.parse(bufread)
.collect_triples()
Expand Down Expand Up @@ -76,7 +76,7 @@ pub trait Loader: Sync + Sized {

#[cfg(feature = "xml")]
"application/rdf+xml" => sophia_xml::parser::RdfXmlParser {
base: Some(iri.as_ref().map_unchecked(|t| t.borrow().to_string())),
base: Some(iri.as_ref().map_unchecked(|t| t.to_string())),
}
.parse(bufread)
.collect_triples()
Expand Down
12 changes: 3 additions & 9 deletions term/src/_generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,15 @@ impl<T: Borrow<str> + Debug> Term for GenericTerm<T> {

fn iri(&self) -> Option<IriRef<sophia_api::MownStr>> {
if let GenericTerm::Iri(iri) = self {
Some(
iri.as_ref()
.map_unchecked(|t| MownStr::from_str(t.borrow())),
)
Some(iri.as_ref().map_unchecked(MownStr::from_str))
} else {
None
}
}

fn bnode_id(&self) -> Option<BnodeId<sophia_api::MownStr>> {
if let GenericTerm::BlankNode(id) = self {
Some(id.as_ref().map_unchecked(|t| MownStr::from_str(t.borrow())))
Some(id.as_ref().map_unchecked(MownStr::from_str))
} else {
None
}
Expand Down Expand Up @@ -116,10 +113,7 @@ impl<T: Borrow<str> + Debug> Term for GenericTerm<T> {

fn variable(&self) -> Option<VarName<sophia_api::MownStr>> {
if let GenericTerm::Variable(name) = self {
Some(
name.as_ref()
.map_unchecked(|t| MownStr::from_str(t.borrow())),
)
Some(name.as_ref().map_unchecked(MownStr::from_str))
} else {
None
}
Expand Down
6 changes: 3 additions & 3 deletions term/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod test {
let mut old_len = stash.len();

let t1a = sophia_api::ns::xsd::integer;
let t1b = stash.copy_term(&t1a);
let t1b = stash.copy_term(t1a);
assert!(Term::eq(&t1a, &t1b));
assert_eq!(old_len + 1, stash.len());
old_len = stash.len();
Expand All @@ -68,13 +68,13 @@ mod test {
old_len = stash.len();

let t5a = BnodeId::new_unchecked("foo");
let t5b = stash.copy_term(&t5a);
let t5b = stash.copy_term(t5a);
assert!(Term::eq(&t5a, &t5b));
assert_eq!(old_len, stash.len()); // all values where alreadt there
old_len = stash.len();

let t6a = VarName::new_unchecked("foobar");
let t6b = stash.copy_term(&t6a);
let t6b = stash.copy_term(t6a);
assert!(Term::eq(&t6a, &t6b));
assert_eq!(old_len + 1, stash.len()); // all values where alreadt there
old_len = stash.len();
Expand Down

0 comments on commit 719f7eb

Please sign in to comment.