Skip to content

Commit 9d55b8f

Browse files
mkatychevpchampin
authored andcommitted
cargo fmt
1 parent b67d9ad commit 9d55b8f

File tree

29 files changed

+127
-75
lines changed

29 files changed

+127
-75
lines changed

iri/src/_regex.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use regex::Regex;
88
/// is not `None`.
99
/// Future implementations may be smarter about this.
1010
#[inline]
11-
#[must_use] pub fn is_valid_suffixed_iri_ref(ns: &str, suffix: Option<&str>) -> bool {
11+
#[must_use]
12+
pub fn is_valid_suffixed_iri_ref(ns: &str, suffix: Option<&str>) -> bool {
1213
match suffix {
1314
None => is_valid_iri_ref(ns),
1415
Some(suffix) => {
@@ -22,19 +23,22 @@ use regex::Regex;
2223

2324
/// Check whether `txt` is a valid (absolute or relative) IRI reference.
2425
#[inline]
25-
#[must_use] pub fn is_valid_iri_ref(txt: &str) -> bool {
26+
#[must_use]
27+
pub fn is_valid_iri_ref(txt: &str) -> bool {
2628
IRI_REGEX.is_match(txt) || IRELATIVE_REF_REGEX.is_match(txt)
2729
}
2830

2931
/// Check whether `txt` is an absolute IRI reference.
3032
#[inline]
31-
#[must_use] pub fn is_absolute_iri_ref(txt: &str) -> bool {
33+
#[must_use]
34+
pub fn is_absolute_iri_ref(txt: &str) -> bool {
3235
IRI_REGEX.is_match(txt)
3336
}
3437

3538
/// Check whether `txt` is a relative IRI reference.
3639
#[inline]
37-
#[must_use] pub fn is_relative_iri_ref(txt: &str) -> bool {
40+
#[must_use]
41+
pub fn is_relative_iri_ref(txt: &str) -> bool {
3842
IRELATIVE_REF_REGEX.is_match(txt)
3943
}
4044

iri/src/_wrapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! I provide generic wrappers around `Borrow<str>` types,
22
//! guaranteeing that their underlying string is a valid IRI or IRI reference.
33
use super::resolve::{BaseIri, BaseIriRef};
4-
use super::{InvalidIri, IsIri, IsIriRef, Result, is_absolute_iri_ref, is_valid_iri_ref, wrap};
4+
use super::{is_absolute_iri_ref, is_valid_iri_ref, wrap, InvalidIri, IsIri, IsIriRef, Result};
55
use std::borrow::Borrow;
66
use std::fmt::Display;
77

isomorphism/src/dataset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::hash::hash_quad_with;
2-
use super::iso_term::{IsoTerm, cmp_quads};
2+
use super::iso_term::{cmp_quads, IsoTerm};
33
use sophia_api::quad::{iter_spog, Quad};
44
use sophia_api::{
55
dataset::{DTerm, Dataset},

isomorphism/src/test.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ fn quoted_triple() -> Result<(), Box<dyn Error>> {
149149

150150
fn make_chain(ids: &'static str) -> Vec<[MyTerm; 4]> {
151151
let rel = MyTerm::Iri("tag:rel");
152-
let nodes: Vec<_> = (0..ids.len())
153-
.map(|i| MyTerm::Bnode(&ids[i..=i]))
154-
.collect();
152+
let nodes: Vec<_> = (0..ids.len()).map(|i| MyTerm::Bnode(&ids[i..=i])).collect();
155153
let mut dataset = Vec::with_capacity(ids.len() - 1);
156154
for i in 1..nodes.len() {
157155
dataset.push([nodes[i - 1], rel, nodes[i], nodes[i - 1]]);
@@ -236,9 +234,7 @@ fn cycle_almost_pathological() -> Result<(), Box<dyn Error>> {
236234

237235
fn make_clique(ids: &'static str) -> Vec<[MyTerm; 4]> {
238236
let rel = MyTerm::Iri("tag:rel");
239-
let nodes: Vec<_> = (0..ids.len())
240-
.map(|i| MyTerm::Bnode(&ids[i..=i]))
241-
.collect();
237+
let nodes: Vec<_> = (0..ids.len()).map(|i| MyTerm::Bnode(&ids[i..=i])).collect();
242238
let mut dataset = Vec::with_capacity(ids.len() * ids.len());
243239
for n1 in &nodes {
244240
for n2 in &nodes {
@@ -264,9 +260,7 @@ fn clique() -> Result<(), Box<dyn Error>> {
264260

265261
fn make_tree(ids: &'static str) -> Vec<[MyTerm; 4]> {
266262
let rel = MyTerm::Iri("tag:rel");
267-
let nodes: Vec<_> = (0..ids.len())
268-
.map(|i| MyTerm::Bnode(&ids[i..=i]))
269-
.collect();
263+
let nodes: Vec<_> = (0..ids.len()).map(|i| MyTerm::Bnode(&ids[i..=i])).collect();
270264
let mut dataset = Vec::with_capacity(ids.len() * ids.len());
271265
let mut i = 0;
272266
while 2 * i < nodes.len() {

jsonld/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ impl TryIntoContextRef for &str {
4848
fn try_into_context_ref(self) -> Result<ContextRef, Self::Error> {
4949
let iri = ArcIri::new_unchecked("x-string://".into());
5050
let doc = Value::parse_str(self, |span| locspan::Location::new(iri.clone(), span))?;
51-
let context = Value::extract_context(doc)
52-
.map_err(|e| format!("Could not extract @context: {e}"))?;
51+
let context =
52+
Value::extract_context(doc).map_err(|e| format!("Could not extract @context: {e}"))?;
5353
let rdoc = RemoteDocument::new(None, None, context);
5454
Ok(RemoteDocumentReference::Loaded(rdoc))
5555
}

jsonld/src/loader/file_url_loader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ impl Loader<Iri<Arc<str>>, Location<Iri<Arc<str>>>> for FileUrlLoader {
6868

6969
impl FileUrlLoader {
7070
/// Creates a new file system loader with the given content `parser`.
71-
#[must_use] pub fn new() -> Self {
71+
#[must_use]
72+
pub fn new() -> Self {
7273
Self::default()
7374
}
7475
}

jsonld/src/loader/static_loader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ impl<I, S> Default for StaticLoader<I, S> {
3333

3434
impl<I: IsIri, S> StaticLoader<I, S> {
3535
/// Creates a new [`StaticLoader`]
36-
#[must_use] pub fn new() -> Self {
36+
#[must_use]
37+
pub fn new() -> Self {
3738
Self::default()
3839
}
3940

jsonld/src/loader_factory.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ where
4545
{
4646
/// Create a new [`DefaultLoaderFactory`].
4747
#[inline]
48-
#[must_use] pub fn new() -> Self {
48+
#[must_use]
49+
pub fn new() -> Self {
4950
Self::default()
5051
}
5152
}

jsonld/src/options.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ pub struct JsonLdOptions<LF> {
4343

4444
impl JsonLdOptions<DefaultLoaderFactory<NoLoader>> {
4545
/// Build a new JSON-LD options.
46-
#[must_use] pub fn new() -> Self {
46+
#[must_use]
47+
pub fn new() -> Self {
4748
Self::default()
4849
}
4950
}

jsonld/src/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ impl Default for JsonLdParser<DefaultLoaderFactory<NoLoader>> {
5151

5252
impl JsonLdParser<DefaultLoaderFactory<NoLoader>> {
5353
/// Make a new [`JsonLdParser`] with the default options
54-
#[must_use] pub fn new() -> Self {
54+
#[must_use]
55+
pub fn new() -> Self {
5556
Self {
5657
options: JsonLdOptions::default(),
5758
}

jsonld/src/serializer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ pub struct JsonTarget(JsonValue<()>);
115115
impl Jsonifier {
116116
/// Create a new serializer which targets a [`JsonValue`].
117117
#[inline]
118-
#[must_use] pub fn new_jsonifier() -> Self {
118+
#[must_use]
119+
pub fn new_jsonifier() -> Self {
119120
Self::new(JsonTarget(JsonValue::Null))
120121
}
121122
}
@@ -165,7 +166,8 @@ pub type JsonLdStringifier<L = NoLoader> = JsonLdSerializer<Vec<u8>, L>;
165166
impl JsonLdStringifier<NoLoader> {
166167
/// Create a new serializer which targets a string.
167168
#[inline]
168-
#[must_use] pub fn new_stringifier() -> Self {
169+
#[must_use]
170+
pub fn new_stringifier() -> Self {
169171
Self::new(Vec::new())
170172
}
171173
}

jsonld/src/serializer/engine.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use super::rdf_object::RdfObject;
22
use crate::error::JsonLdError;
3-
use crate::options::{ProcessingMode::{JsonLd1_0, JsonLd1_1}, JsonLdOptions, RdfDirection};
3+
use crate::options::{
4+
JsonLdOptions,
5+
ProcessingMode::{JsonLd1_0, JsonLd1_1},
6+
RdfDirection,
7+
};
48
use crate::util_traits::{HashMapUtil, QuadJsonLdUtil, TermJsonLdUtil, VecUtil};
59
use json_syntax::object::Object;
610
use json_syntax::{Parse, Value as JsonValue};
@@ -122,7 +126,9 @@ impl<'a, L> Engine<'a, L> {
122126
where
123127
T: Term,
124128
{
125-
if o.kind() == TermKind::Literal { RdfObject::try_from_term(o).unwrap() } else {
129+
if o.kind() == TermKind::Literal {
130+
RdfObject::try_from_term(o).unwrap()
131+
} else {
126132
let o_id = o.as_id();
127133
RdfObject::Node(self.index(g_id.to_string(), o_id.clone()), o_id)
128134
}

jsonld/src/serializer/rdf_object.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ pub enum RdfObject {
1010

1111
impl RdfObject {
1212
pub const fn is_literal(&self) -> bool {
13-
matches!(
14-
self,
15-
Self::LangString(..) | Self::TypedLiteral(..)
16-
)
13+
matches!(self, Self::LangString(..) | Self::TypedLiteral(..))
1714
}
1815
pub const fn is_node(&self) -> bool {
1916
matches!(self, Self::Node(..))

jsonld/src/util_traits.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Utility traits used internally by `JsonLdSerializer`
22
use sophia_api::quad::Quad;
3-
use sophia_api::term::{Term, TermKind::{BlankNode, Iri, Literal}};
3+
use sophia_api::term::{
4+
Term,
5+
TermKind::{BlankNode, Iri, Literal},
6+
};
47
use std::collections::hash_map::Entry::{Occupied, Vacant};
58
use std::collections::HashMap;
69

resource/src/loader/_error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pub enum LoaderError {
2525

2626
impl LoaderError {
2727
/// Return the IRI that caused this error
28-
#[must_use] pub fn iri(&self) -> IriBuf {
28+
#[must_use]
29+
pub fn iri(&self) -> IriBuf {
2930
let iri = match self {
3031
Self::UnsupportedIri(iri, _) => iri,
3132
Self::NotFound(iri) => iri,

resource/src/loader/_local.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use super::{util::{IriBuf, iri_buf}, Loader, LoaderError};
1+
use super::{
2+
util::{iri_buf, IriBuf},
3+
Loader, LoaderError,
4+
};
25
use sophia_iri::Iri;
36
use std::borrow::Borrow;
47
use std::fmt::Debug;
@@ -41,7 +44,8 @@ impl LocalLoader {
4144
}
4245

4346
/// Wrap this loader into an `Arc<Loader>`.
44-
#[must_use] pub fn arced(self) -> Arc<Self> {
47+
#[must_use]
48+
pub fn arced(self) -> Arc<Self> {
4549
Arc::new(self)
4650
}
4751

resource/src/resource/_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::marker::PhantomData;
22

3-
use super::{Resource, ResourceError::NoValueFor, ResourceError, ResourceResult, TypedResource};
3+
use super::{Resource, ResourceError, ResourceError::NoValueFor, ResourceResult, TypedResource};
44
use crate::Loader;
55
use sophia_api::{graph::CollectibleGraph, prelude::*, term::SimpleTerm};
66

resource/src/resource/_struct.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ use sophia_iri::is_absolute_iri_ref;
88
use std::borrow::Borrow;
99
use std::sync::Arc;
1010

11-
use super::{ResourceError::{GraphError, IriNotAbsolute, LoaderError, NoValueFor, UnexpectedMultipleValueFor}, LadderResourceIterator, LadderTermIterator, LadderTypedIterator, ResourceError, ResourceResult, TypedResource};
11+
use super::{
12+
LadderResourceIterator, LadderTermIterator, LadderTypedIterator, ResourceError,
13+
ResourceError::{
14+
GraphError, IriNotAbsolute, LoaderError, NoValueFor, UnexpectedMultipleValueFor,
15+
},
16+
ResourceResult, TypedResource,
17+
};
1218

1319
/// A [`Resource`] represents a specific node in a given graph.
1420
#[derive(Debug)]
@@ -36,22 +42,26 @@ where
3642
}
3743

3844
/// The identifying term of this resource
39-
#[must_use] pub const fn id(&self) -> &SimpleTerm<'static> {
45+
#[must_use]
46+
pub const fn id(&self) -> &SimpleTerm<'static> {
4047
&self.id
4148
}
4249

4350
/// The URL of the underlying graph of this resource
44-
#[must_use] pub const fn base(&self) -> Option<&Iri<String>> {
51+
#[must_use]
52+
pub const fn base(&self) -> Option<&Iri<String>> {
4553
self.base.as_ref()
4654
}
4755

4856
/// The underlying graph of this resource
49-
#[must_use] pub const fn graph(&self) -> &Arc<G> {
57+
#[must_use]
58+
pub const fn graph(&self) -> &Arc<G> {
5059
&self.graph
5160
}
5261

5362
/// The loader used to load neighbouring resources
54-
#[must_use] pub const fn loader(&self) -> &Arc<L> {
63+
#[must_use]
64+
pub const fn loader(&self) -> &Arc<L> {
5565
&self.loader
5666
}
5767

rio/src/model.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
//! which ensures the validity of the underlying data.
99
//!
1010
//! The [`Trusted`] wrapper is used to materialize the fact that we trust the underlying data of Rio types.
11-
use rio_api::model::{Quad as RioQuad, Term as RioTerm, Triple as RioTriple, BlankNode, GeneralizedQuad, GeneralizedTerm, GraphName, Literal, NamedNode, Variable};
11+
use rio_api::model::{
12+
BlankNode, GeneralizedQuad, GeneralizedTerm, GraphName, Literal, NamedNode, Quad as RioQuad,
13+
Term as RioTerm, Triple as RioTriple, Variable,
14+
};
1215
use sophia_api::ns::{rdf, xsd};
1316
use sophia_api::quad::{QBorrowTerm, Quad, Spog};
1417
use sophia_api::term::{BnodeId, LanguageTag, Term, TermKind, VarName};

rio/src/parser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
use std::error::Error;
1010

1111
use crate::model::Trusted;
12-
use sophia_api::source::{StreamError, StreamError::{SinkError, SourceError}, StreamResult};
12+
use sophia_api::source::{
13+
StreamError,
14+
StreamError::{SinkError, SourceError},
15+
StreamResult,
16+
};
1317

1418
/// Wrap a Rio [`TriplesParser`](rio_api::parser::TriplesParser)
1519
/// into a Sophia [`TripleSource`](sophia_api::source::TripleSource).

sophia/examples/jsonld-context.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1919
let json_ld_path = args.nth(1).expect("Missing jsonld file.");
2020
let context_path = args.next();
2121
if let Some(context_path) = &context_path {
22-
eprintln!(
23-
"Loading {json_ld_path} with @context from {context_path}"
24-
);
22+
eprintln!("Loading {json_ld_path} with @context from {context_path}");
2523
} else {
2624
eprintln!("Loading {json_ld_path}");
2725
}

sophia/examples/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ fn main() {
8383
"gtrig" => dump_quads(input, GTriGParser { base }),
8484
#[cfg(feature = "jsonld")]
8585
"json-ld" | "jsonld" => {
86-
let options = JsonLdOptions::new()
87-
.with_base(base.unwrap().map_unchecked(std::sync::Arc::from));
86+
let options =
87+
JsonLdOptions::new().with_base(base.unwrap().map_unchecked(std::sync::Arc::from));
8888
let loader_factory = sophia::jsonld::loader::FileUrlLoader::default;
8989
#[cfg(feature = "http_client")]
9090
let loader_factory = || {

term/src/_generic.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ impl<T: Borrow<str> + for<'x> From<&'x str>> TryFromTerm for GenericLiteral<T> {
8888
} else {
8989
// the following is safe because we checked term.kind()
9090
let dt = unsafe { term.datatype().unwrap_unchecked() };
91-
Ok(Self::Typed(
92-
lex,
93-
dt.map_unchecked(|txt| T::from(&txt)),
94-
))
91+
Ok(Self::Typed(lex, dt.map_unchecked(|txt| T::from(&txt))))
9592
}
9693
} else {
9794
Err(GenericLiteralError(term.kind()))

term/src/_macro.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,14 @@ macro_rules! gen_stash {
330330

331331
impl $type_name {
332332
/// Create a new empty stash
333-
#[must_use] pub fn new() -> Self {
333+
#[must_use]
334+
pub fn new() -> Self {
334335
Default::default()
335336
}
336337

337338
/// Retrieve a value from the stash, if present
338-
#[must_use] pub fn get(&self, probe: &str) -> Option<&W<str>> {
339+
#[must_use]
340+
pub fn get(&self, probe: &str) -> Option<&W<str>> {
339341
self.store.get(probe)
340342
}
341343

@@ -352,12 +354,14 @@ macro_rules! gen_stash {
352354
}
353355

354356
/// How many values are stored in this stash
355-
#[must_use] pub fn len(&self) -> usize {
357+
#[must_use]
358+
pub fn len(&self) -> usize {
356359
self.store.len()
357360
}
358361

359362
/// Is this stash empty?
360-
#[must_use] pub fn is_empty(&self) -> bool {
363+
#[must_use]
364+
pub fn is_empty(&self) -> bool {
361365
self.store.is_empty()
362366
}
363367
}

0 commit comments

Comments
 (0)