Skip to content

Commit

Permalink
clippy: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed May 23, 2024
1 parent 6f42a1a commit 609fbcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/draft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl Draft {
if let Some(i) = ptr.find('/') {
(&ptr[..i], &ptr[i..])
} else {
(&ptr, "")
(ptr, "")
}
}

Expand Down
28 changes: 10 additions & 18 deletions src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,21 +1020,6 @@ pub enum InstanceToken<'v> {
Item(usize),
}

impl<'v> InstanceToken<'v> {
fn to_string(tokens: &[InstanceToken]) -> String {
use InstanceToken::*;
let mut r = String::new();
for tok in tokens {
r.push('/');
match tok {
Prop(s) => r.push_str(&escape(s)),
Item(i) => write!(&mut r, "{i}").expect("write to String should never fail"),
}
}
r
}
}

impl<'v> From<String> for InstanceToken<'v> {
fn from(prop: String) -> Self {
InstanceToken::Prop(prop.into())
Expand Down Expand Up @@ -1077,9 +1062,16 @@ impl<'v> InstanceLocation<'v> {
}
}

impl<'v> ToString for InstanceLocation<'v> {
fn to_string(&self) -> String {
InstanceToken::to_string(&self.tokens)
impl<'v> Display for InstanceLocation<'v> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for tok in &self.tokens {
f.write_char('/')?;
match tok {
InstanceToken::Prop(s) => f.write_str(&escape(s))?,
InstanceToken::Item(i) => write!(f, "{i}")?,
}
}
Ok(())
}
}

Expand Down

0 comments on commit 609fbcf

Please sign in to comment.