Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt+clippy #169

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/classic/clvm/__type_compatibility__.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn char_to_string(ch: char) -> String {
}

pub fn vec_to_string(r: &[u8]) -> String {
return String::from_utf8_lossy(r).as_ref().to_string();
String::from_utf8_lossy(r).as_ref().to_string()
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/classic/clvm/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a> SExpToBytesIterator<'a> {
}
}

impl<'a> Iterator for SExpToBytesIterator<'a> {
impl Iterator for SExpToBytesIterator<'_> {
type Item = Vec<u8>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -281,6 +281,6 @@ pub fn atom_from_stream<'a>(
if blob.length() != size as usize {
return Err(EvalErr(NodePtr::NIL, "bad encoding".to_string()));
}
return allocator.new_atom(blob.data());
allocator.new_atom(blob.data())
})
}
4 changes: 2 additions & 2 deletions src/classic/clvm/sexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub fn to_sexp_type(allocator: &mut Allocator, value: CastableType) -> Result<No
));
}

return match stack.pop() {
match stack.pop() {
None => Err(EvalErr(NodePtr::NIL, "stack empty".to_string())),
Some(top) => match top.borrow() {
CastableType::CLVMObject(o) => Ok(*o),
Expand All @@ -211,7 +211,7 @@ pub fn to_sexp_type(allocator: &mut Allocator, value: CastableType) -> Result<No
format!("unimplemented {:?}", stack[0]),
)),
},
};
}
}

pub fn sexp_as_bin(allocator: &mut Allocator, sexp: NodePtr) -> Bytes {
Expand Down
62 changes: 28 additions & 34 deletions src/classic/clvm_tools/stages/stage_2/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub fn cons_q_a_optimizer(

let matched = match_sexp(allocator, cons_q_a_optimizer_pattern, r, HashMap::new());

return match (
match (
matched.as_ref().and_then(|t1| t1.get("args").copied()),
matched.as_ref().and_then(|t1| t1.get("sexp").copied()),
) {
Expand All @@ -177,7 +177,7 @@ pub fn cons_q_a_optimizer(
}
}
_ => Ok(r),
};
}
}

fn cons_pattern(allocator: &mut Allocator) -> NodePtr {
Expand Down Expand Up @@ -521,41 +521,35 @@ fn path_optimizer(
let first_match = match_sexp(allocator, first_atom_pattern, r, HashMap::new());
let rest_match = match_sexp(allocator, rest_atom_pattern, r, HashMap::new());

return m! {
match (first_match, rest_match) {
(Some(first), _) => {
match first.
get("atom").
and_then(|a| atom(allocator, *a).ok()).
map(|atom| number_from_u8(&atom))
{
Some(atom) => {
let node =
NodePath::new(Some(atom)).
add(NodePath::new(None).first());
allocator.new_atom(node.as_path().data())
},
_ => { Ok(r) }
match (first_match, rest_match) {
(Some(first), _) => {
match first
.get("atom")
.and_then(|a| atom(allocator, *a).ok())
.map(|atom| number_from_u8(&atom))
{
Some(atom) => {
let node = NodePath::new(Some(atom)).add(NodePath::new(None).first());
allocator.new_atom(node.as_path().data())
}
},
(_, Some(rest)) => {
match rest.
get("atom").
and_then(|a| atom(allocator, *a).ok()).
map(|atom| number_from_u8(&atom))
{
Some(atom) => {
let node =
NodePath::new(Some(atom)).
add(NodePath::new(None).rest());
allocator.new_atom(node.as_path().data())
},
_ => { Ok(r) }
_ => Ok(r),
}
}
(_, Some(rest)) => {
match rest
.get("atom")
.and_then(|a| atom(allocator, *a).ok())
.map(|atom| number_from_u8(&atom))
{
Some(atom) => {
let node = NodePath::new(Some(atom)).add(NodePath::new(None).rest());
allocator.new_atom(node.as_path().data())
}
},
_ => Ok(r)
_ => Ok(r),
}
}
};
_ => Ok(r),
}
}

fn quote_pattern_1(allocator: &mut Allocator) -> NodePtr {
Expand Down
4 changes: 2 additions & 2 deletions src/classic/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ impl ArgumentValueConv for PathJoin {
fn convert(&self, arg: &str) -> Result<ArgumentValue, String> {
let mut p = PathBuf::new();
p.push(arg);
return Ok(ArgumentValue::ArgString(
Ok(ArgumentValue::ArgString(
None,
p.as_path().to_str().unwrap().to_string(),
));
))
}
}
2 changes: 1 addition & 1 deletion src/compiler/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ trait VisitedInfoAccess {
fn insert_function(&mut self, name: Vec<u8>, body: Rc<BodyForm>);
}

impl<'info> VisitedInfoAccess for VisitedMarker<'info, VisitedInfo> {
impl VisitedInfoAccess for VisitedMarker<'_, VisitedInfo> {
fn get_function(&mut self, name: &[u8]) -> Option<Rc<BodyForm>> {
if let Some(ref mut info) = self.info {
info.functions.get(name).cloned()
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl<'a> CompileContextWrapper<'a> {

/// Drop CompileContextWrapper reverts the contained objects back to the ones
/// owned by the caller.
impl<'a> Drop for CompileContextWrapper<'a> {
impl Drop for CompileContextWrapper<'_> {
fn drop(&mut self) {
self.switch();
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/sexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ fn list_no_parens(a: &SExp, b: &SExp) -> String {
}

pub fn decode_string(v: &[u8]) -> String {
return String::from_utf8_lossy(v).as_ref().to_string();
String::from_utf8_lossy(v).as_ref().to_string()
}

pub fn printable(a: &[u8], quoted: bool) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/stackvisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'info, T> VisitedMarker<'info, T> {
}
}

impl<'info, T> Unvisit<T> for VisitedMarker<'info, T> {
impl<T> Unvisit<T> for VisitedMarker<'_, T> {
fn give_back(&mut self, info: Option<Box<T>>) {
self.info = info;
}
Expand All @@ -66,7 +66,7 @@ impl<'info, T> Unvisit<T> for VisitedMarker<'info, T> {
}

// When dropped, the info box is handed back.
impl<'info, T> Drop for VisitedMarker<'info, T> {
impl<T> Drop for VisitedMarker<'_, T> {
fn drop(&mut self) {
let mut info = None;
swap(&mut self.info, &mut info);
Expand Down
2 changes: 1 addition & 1 deletion src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
}

pub fn skip_leading(s: &str, dash: &str) -> String {
return s.graphemes(true).skip_while(|ch| dash == *ch).collect();
s.graphemes(true).skip_while(|ch| dash == *ch).collect()
}

pub fn collapse<A>(r: Result<A, A>) -> A {
Expand Down
Loading