Skip to content

Commit

Permalink
style(cognitarium): little coup de polish
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Nov 2, 2023
1 parent 70ba5a8 commit cc94b6d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion contracts/okp4-cognitarium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ cosmwasm-storage.workspace = true
cw-storage-plus.workspace = true
cw2.workspace = true
derive_builder = "0.12.0"
either = "1.9.0"
rio_api = "0.8.4"
rio_turtle = "0.8.4"
rio_xml = "0.8.4"
either = "1.9.0"
schemars.workspace = true
serde.workspace = true
thiserror.workspace = true
Expand Down
18 changes: 9 additions & 9 deletions contracts/okp4-cognitarium/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ pub mod query {
let out: Vec<u8> = Vec::default();
let mut writer = TripleWriter::new(&format, out);

for atom in atoms {
let rdf_triple = (&atom).into();
for atom in &atoms {
let triple = atom.into();

writer.write(&rdf_triple).map_err(|e| {
writer.write(&triple).map_err(|e| {
StdError::serialize_err(
"triple",
format!("Error writing triple {}: {}", &rdf_triple, e),
format!("Error writing triple {}: {}", &triple, e),
)
})?;
}
Expand Down Expand Up @@ -287,12 +287,12 @@ pub mod query {
let out: Vec<u8> = Vec::default();
let mut writer = TripleWriter::new(&format, out);

for atom in atoms {
let rdf_triple = (&atom).into();
writer.write(&rdf_triple).map_err(|e| {
for atom in &atoms {
let triple = atom.into();
writer.write(&triple).map_err(|e| {
StdError::serialize_err(
"triple",
format!("Error writing triple {}: {}", &rdf_triple, e),
format!("Error writing triple {}: {}", &triple, e),
)
})?;
}
Expand Down Expand Up @@ -352,7 +352,7 @@ pub mod util {
.into_iter()
.map(|(name, var)| -> StdResult<(String, Value)> {
Ok((
name.clone(),
name,
var.as_value(&mut |ns_key| {
let res = ns_resolver.resolve_from_key(deps.storage, ns_key);
res.and_then(NamespaceResolver::none_as_error_middleware)
Expand Down
14 changes: 7 additions & 7 deletions contracts/okp4-cognitarium/src/querier/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'a> QueryEngine<'a> {
&'a self,
plan: QueryPlan,
selection: Vec<SelectItem>,
) -> StdResult<SelectResults> {
) -> StdResult<SelectResults<'_>> {
let bindings = selection
.iter()
.map(|item| match item {
Expand Down Expand Up @@ -538,7 +538,7 @@ impl TripleTemplate {
let subject = match Self::resolve_triple_term(
&self.subject,
ResolvedVariable::as_subject,
&vars,
vars,
"subject",
)? {
Some(s) => s,
Expand All @@ -548,7 +548,7 @@ impl TripleTemplate {
let predicate = match Self::resolve_triple_term(
&self.predicate,
ResolvedVariable::as_predicate,
&vars,
vars,
"predicate",
)? {
Some(p) => p,
Expand All @@ -558,17 +558,17 @@ impl TripleTemplate {
let object = match Self::resolve_triple_term(
&self.object,
ResolvedVariable::as_object,
&vars,
vars,
"object",
)? {
Some(o) => o,
None => return Ok(None),

Check warning on line 565 in contracts/okp4-cognitarium/src/querier/engine.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-cognitarium/src/querier/engine.rs#L565

Added line #L565 was not covered by tests
};

Ok(Some(Triple {
subject: subject.clone(),
predicate: predicate.clone(),
object: object.clone(),
subject,
predicate,
object,
}))
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/okp4-cognitarium/src/storer/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'a> StoreEngine<'a> {
)
.map_err(ContractError::Std)?;

if let Some(_) = old {
if old.is_some() {
triples().replace(
self.storage,
(
Expand Down Expand Up @@ -246,7 +246,7 @@ impl<'a> StoreEngine<'a> {

fn subject_size(&mut self, subject: &Subject) -> StdResult<usize> {
match subject {
Subject::Named(n) => self.node_size(&n),
Subject::Named(n) => self.node_size(n),
Subject::Blank(n) => Ok(n.len()),
}
}
Expand Down

0 comments on commit cc94b6d

Please sign in to comment.