Skip to content

Commit

Permalink
remove implicit uses of std
Browse files Browse the repository at this point in the history
  • Loading branch information
asmello committed Apr 3, 2024
1 parent 7232a1e commit 07ea961
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
8 changes: 6 additions & 2 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use crate::{PointerBuf, Token};
use alloc::{
boxed::Box,
string::{String, ToString},
vec::Vec,
};
use quickcheck::Arbitrary;

impl Arbitrary for Token {
Expand All @@ -7,8 +12,7 @@ impl Arbitrary for Token {
}

fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
let s = self.to_string();
Box::new(s.shrink().map(Self::new))
Box::new(ToString::to_string(self).shrink().map(Self::new))
}
}

Expand Down
25 changes: 8 additions & 17 deletions src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ impl Pointer {
match token.as_str() {
"0" => {
// first element will be traversed when we recurse
*dest = vec![Value::Null].into();
*dest = alloc::vec![Value::Null].into();
}
"-" => {
// new element will be appended when we recurse
Expand Down Expand Up @@ -994,14 +994,13 @@ impl core::fmt::Display for PointerBuf {

#[cfg(test)]
mod tests {
use super::*;
use crate::{Resolve, ResolveMut};
use alloc::vec;
use quickcheck::TestResult;
use quickcheck_macros::quickcheck;
use serde_json::json;

use crate::{Resolve, ResolveMut};

use super::*;

#[test]
#[should_panic]
fn from_const_validates() {
Expand Down Expand Up @@ -1603,11 +1602,7 @@ mod tests {
while let Some(token) = ptr.pop_back() {
tokens.push(token);
}
if dbg!(ptr.count() != 0)
|| dbg!(!ptr.is_root())
|| dbg!(ptr.last().is_some())
|| dbg!(ptr.first().is_some())
{
if ptr.count() != 0 || !ptr.is_root() || ptr.last().is_some() || ptr.first().is_some() {
return false;
}
for token in tokens.drain(..) {
Expand All @@ -1619,11 +1614,7 @@ mod tests {
while let Some(token) = ptr.pop_front() {
tokens.push(token);
}
if dbg!(ptr.count() != 0)
|| dbg!(!ptr.is_root())
|| dbg!(ptr.last().is_some())
|| dbg!(ptr.first().is_some())
{
if ptr.count() != 0 || !ptr.is_root() || ptr.last().is_some() || ptr.first().is_some() {
return false;
}
for token in tokens {
Expand Down Expand Up @@ -1658,7 +1649,7 @@ mod tests {
}
}
{
let fmt = format!("/{}{tail}", head.encoded());
let fmt = alloc::format!("/{}{tail}", head.encoded());
if Pointer::parse(&fmt).unwrap() != ptr {
return false;
}
Expand Down Expand Up @@ -1693,7 +1684,7 @@ mod tests {
}
}
{
let fmt = format!("{head}/{}", tail.encoded());
let fmt = alloc::format!("{head}/{}", tail.encoded());
if Pointer::parse(&fmt).unwrap() != ptr {
return false;
}
Expand Down

0 comments on commit 07ea961

Please sign in to comment.