Skip to content

Commit

Permalink
chore: fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Dec 15, 2024
1 parent f464b8d commit 10cb315
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion crates/jsonschema-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn to_error_message(error: &jsonschema::ValidationError<'_>, mut message: String

struct StringWriter<'a>(&'a mut String);

impl<'a> Write for StringWriter<'a> {
impl Write for StringWriter<'_> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
// SAFETY: `serde_json` always produces valid UTF-8
self.0
Expand Down
2 changes: 1 addition & 1 deletion crates/jsonschema-referencing/src/anchors/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl PartialEq for (dyn BorrowDyn + '_) {
}
}

impl<'a> Hash for (dyn BorrowDyn + 'a) {
impl Hash for (dyn BorrowDyn + '_) {
fn hash<H: Hasher>(&self, state: &mut H) {
self.borrowed_key().hash(state);
}
Expand Down
6 changes: 3 additions & 3 deletions crates/jsonschema-referencing/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub struct Resolver<'r> {
scopes: List<Uri<String>>,
}

impl<'r> PartialEq for Resolver<'r> {
impl PartialEq for Resolver<'_> {
fn eq(&self, other: &Self) -> bool {
self.base_uri == other.base_uri
}
}
impl<'r> Eq for Resolver<'r> {}
impl Eq for Resolver<'_> {}

impl<'r> fmt::Debug for Resolver<'r> {
impl fmt::Debug for Resolver<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Resolver")
.field("base_uri", &self.base_uri.as_str())
Expand Down
2 changes: 1 addition & 1 deletion crates/jsonschema-referencing/src/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a> From<Cow<'a, str>> for Segment<'a> {
}
}

impl<'a> From<usize> for Segment<'a> {
impl From<usize> for Segment<'_> {
fn from(value: usize) -> Self {
Segment::Index(value)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/jsonschema-referencing/tests/suite
Submodule suite updated 1 files
+2 −2 .pre-commit-config.yaml
7 changes: 4 additions & 3 deletions crates/jsonschema/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ impl<'a> Context<'a> {
!matches!(self.draft, Draft::Draft4)
}
pub(crate) fn validates_formats_by_default(&self) -> bool {
self.config
.validate_formats()
.unwrap_or_else(|| matches!(self.draft, Draft::Draft4 | Draft::Draft6 | Draft::Draft7))
self.config.validate_formats().unwrap_or(matches!(
self.draft,
Draft::Draft4 | Draft::Draft6 | Draft::Draft7
))
}
pub(crate) fn are_unknown_formats_ignored(&self) -> bool {
self.config.are_unknown_formats_ignored()
Expand Down
8 changes: 4 additions & 4 deletions crates/jsonschema/src/keywords/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,12 @@ impl Validate for CustomFormatValidator {
if self.is_valid(instance) {
Ok(())
} else {
return Err(ValidationError::format(
Err(ValidationError::format(
self.location.clone(),
location.into(),
instance,
self.format_name.clone(),
));
))
}
}

Expand Down Expand Up @@ -797,12 +797,12 @@ pub(crate) fn compile<'a>(
if ctx.are_unknown_formats_ignored() {
None
} else {
return Some(Err(ValidationError::format(
Some(Err(ValidationError::format(
Location::new(),
ctx.location().clone(),
schema,
"unknown format",
)));
)))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/jsonschema/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl<'a> Iterator for NodeValidatorsIter<'a> {
}
}

impl<'a> ExactSizeIterator for NodeValidatorsIter<'a> {
impl ExactSizeIterator for NodeValidatorsIter<'_> {
fn len(&self) -> usize {
match self {
Self::NoValidator => 0,
Expand Down
18 changes: 9 additions & 9 deletions crates/jsonschema/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Output<'a, 'b> {
instance: &'b serde_json::Value,
}

impl<'a, 'b> Output<'a, 'b> {
impl<'a> Output<'a, '_> {
pub(crate) const fn new<'c, 'd>(
schema: &'c Validator,
root_node: &'c SchemaNode,
Expand Down Expand Up @@ -117,7 +117,7 @@ pub enum BasicOutput<'a> {
Invalid(VecDeque<OutputUnit<ErrorDescription>>),
}

impl<'a> BasicOutput<'a> {
impl BasicOutput<'_> {
/// A shortcut to check whether the output represents passed validation.
#[must_use]
pub const fn is_valid(&self) -> bool {
Expand All @@ -136,7 +136,7 @@ impl<'a> From<OutputUnit<Annotations<'a>>> for BasicOutput<'a> {
}
}

impl<'a> AddAssign for BasicOutput<'a> {
impl AddAssign for BasicOutput<'_> {
fn add_assign(&mut self, rhs: Self) {
match (&mut *self, rhs) {
(BasicOutput::Valid(ref mut anns), BasicOutput::Valid(anns_rhs)) => {
Expand All @@ -153,7 +153,7 @@ impl<'a> AddAssign for BasicOutput<'a> {
}
}

impl<'a> Sum for BasicOutput<'a> {
impl Sum for BasicOutput<'_> {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
let result = BasicOutput::Valid(VecDeque::new());
iter.fold(result, |mut acc, elem| {
Expand All @@ -163,7 +163,7 @@ impl<'a> Sum for BasicOutput<'a> {
}
}

impl<'a> Default for BasicOutput<'a> {
impl Default for BasicOutput<'_> {
fn default() -> Self {
BasicOutput::Valid(VecDeque::new())
}
Expand Down Expand Up @@ -306,7 +306,7 @@ impl<'a> From<&'a serde_json::Value> for Annotations<'a> {
}
}

impl<'a> From<serde_json::Value> for Annotations<'a> {
impl From<serde_json::Value> for Annotations<'_> {
fn from(v: serde_json::Value) -> Self {
Annotations(AnnotationsInner::Value(Box::new(v)))
}
Expand Down Expand Up @@ -342,7 +342,7 @@ impl<'a> From<&'a str> for ErrorDescription {
}
}

impl<'a> serde::Serialize for BasicOutput<'a> {
impl serde::Serialize for BasicOutput<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -362,7 +362,7 @@ impl<'a> serde::Serialize for BasicOutput<'a> {
}
}

impl<'a> serde::Serialize for AnnotationsInner<'a> {
impl serde::Serialize for AnnotationsInner<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -375,7 +375,7 @@ impl<'a> serde::Serialize for AnnotationsInner<'a> {
}
}

impl<'a> serde::Serialize for OutputUnit<Annotations<'a>> {
impl serde::Serialize for OutputUnit<Annotations<'_>> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonschema/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum LocationSegment<'a> {
Index(usize),
}

impl<'a> fmt::Display for LocationSegment<'a> {
impl fmt::Display for LocationSegment<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LocationSegment::Property(property) => f.write_str(property),
Expand All @@ -37,7 +37,7 @@ impl Default for LazyLocation<'_, '_> {
}
}

impl<'a, 'b> LazyLocation<'a, 'b> {
impl<'a> LazyLocation<'a, '_> {
/// Create a root node of a JSON pointer.
pub const fn new() -> Self {
LazyLocation {
Expand Down

0 comments on commit 10cb315

Please sign in to comment.