Skip to content

Commit

Permalink
Apply clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham committed Apr 11, 2024
1 parent 53e490f commit 0b8bd9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl From<RichTerm> for Contract {
impl From<Contract> for RichTerm {
fn from(Contract(c): Contract) -> Self {
match c.as_slice() {
[] => static_access(PREDICATES_LIBRARY, ["always"]).into(),
[] => static_access(PREDICATES_LIBRARY, ["always"]),
// TODO: shouldn't need to clone here
[rt] => rt.clone(),
_ => {
Expand Down
24 changes: 13 additions & 11 deletions src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,16 @@ impl RefsUsage {

/// Extend the usages of `self` with the usages of `other`.
pub fn extend(&mut self, other: RefsUsage) {
self.defs_predicates
.extend(other.defs_predicates.into_iter());
self.defs_contracts.extend(other.defs_contracts.into_iter());
self.props_predicates
.extend(other.props_predicates.into_iter());
self.defs_predicates.extend(other.defs_predicates);
self.defs_contracts.extend(other.defs_contracts);
self.props_predicates.extend(other.props_predicates);
}

/// Returns `true` if the state is empty, i.e. if no definition or property has been used.
pub fn is_empty(&self) -> bool {
self.defs_predicates.is_empty()
&& self.defs_contracts.is_empty()
&& self.props_predicates.is_empty()
}
}

Expand Down Expand Up @@ -431,7 +436,7 @@ impl Environment {
let mut usage_placeholder = RefsUsage::new();

for path in refs_usage.props_predicates.iter() {
let Some(schema) = get_property(&root_schema.schema, &path) else {
let Some(schema) = get_property(&root_schema.schema, path) else {
eprintln!(
"Warning: property `{}` is referenced in the schema but couldn't be found",
path.join("/")
Expand Down Expand Up @@ -470,7 +475,7 @@ impl Environment {
let prop_preds = self
.property_preds
.into_iter()
.filter_map(|(k, v)| Some((Ident::from(k.join("/")), Field::from(v))))
.map(|(k, v)| (Ident::from(k.join("/")), Field::from(v)))
.collect();

// All the definitions as a Nickel record
Expand Down Expand Up @@ -545,10 +550,7 @@ impl Environment {
/// between the two (we can convert between the owned variants easily, but not for refernces).
/// Since we can special case empty paths before calling to `get_property` if really needed, it's
/// simpler to just return `None` here.
pub fn get_property<'a, 'b>(
schema_obj: &'a SchemaObject,
path: &'b [String],
) -> Option<&'a Schema> {
pub fn get_property<'a>(schema_obj: &'a SchemaObject, path: &[String]) -> Option<&'a Schema> {
let mut current: Option<&Schema> = None;

for prop in path {
Expand Down

0 comments on commit 0b8bd9b

Please sign in to comment.