Cargo fmt

This commit is contained in:
Alex 2022-12-15 15:38:10 +01:00
parent 52f6bd177c
commit 1579030b44
Signed by: lx
GPG key ID: 0E496D15096376BE
3 changed files with 60 additions and 62 deletions

View file

@ -378,7 +378,9 @@ impl<'a, 'b> Term<'a, 'b> {
/// ``` /// ```
pub fn list(&self) -> Result<Vec<Term<'a, '_>>, TypeError> { pub fn list(&self) -> Result<Vec<Term<'a, '_>>, TypeError> {
match self.0.mkref() { match self.0.mkref() {
AnyTerm::ListRef(_r, l) => Ok(l.iter().map(|x| Term(x.mkref().into())).collect::<Vec<_>>()), AnyTerm::ListRef(_r, l) => {
Ok(l.iter().map(|x| Term(x.mkref().into())).collect::<Vec<_>>())
}
_ => Err(TypeError::WrongType("LIST")), _ => Err(TypeError::WrongType("LIST")),
} }
} }

View file

@ -312,7 +312,10 @@ impl<'a> T<'a> {
buf.extend_from_slice(b"[]"); buf.extend_from_slice(b"[]");
} else if l.len() == 1 { } else if l.len() == 1 {
buf.extend_from_slice(b"[ "); buf.extend_from_slice(b"[ ");
l.into_iter().next().unwrap().encode_aux(buf, indent + 2, false); l.into_iter()
.next()
.unwrap()
.encode_aux(buf, indent + 2, false);
buf.extend_from_slice(b" ]"); buf.extend_from_slice(b" ]");
} else { } else {
let indent2 = indent + 2; let indent2 = indent + 2;
@ -390,18 +393,15 @@ impl<'a> T<'a> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::debug;
use super::*; use super::*;
use crate::debug;
#[test] #[test]
fn complex1() { fn complex1() {
let input = seq([ let input = seq([
string("HELLO").unwrap(), string("HELLO").unwrap(),
string("alexhelloworld").unwrap(), string("alexhelloworld").unwrap(),
list([ list([string("dude").unwrap(), string("why").unwrap()]),
string("dude").unwrap(),
string("why").unwrap(),
]),
dict([ dict([
("from", string("jxx").unwrap()), ("from", string("jxx").unwrap()),
("subject", string("hello").unwrap()), ("subject", string("hello").unwrap()),
@ -427,10 +427,7 @@ mod tests {
let input = seq([ let input = seq([
string("HELLO").unwrap(), string("HELLO").unwrap(),
string("alexhelloworld").unwrap(), string("alexhelloworld").unwrap(),
list([ list([string("dude").unwrap(), string("why").unwrap()]),
string("dude").unwrap(),
string("why").unwrap(),
]),
dict([ dict([
("from", string("jxx").unwrap()), ("from", string("jxx").unwrap()),
("subject", string("hello").unwrap()), ("subject", string("hello").unwrap()),

View file

@ -11,9 +11,9 @@ pub use ser::{to_bytes, to_term, Serializer};
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
use crate::debug;
fn test_bidir<T: Serialize + for<'de> Deserialize<'de> + PartialEq + std::fmt::Debug>( fn test_bidir<T: Serialize + for<'de> Deserialize<'de> + PartialEq + std::fmt::Debug>(
input: T, input: T,
@ -96,8 +96,7 @@ mod tests {
E::Struct { a: 1 }, E::Struct { a: 1 },
E::Tuple(3, 2), E::Tuple(3, 2),
]; ];
let expected = let expected = r#"[E.Unit,E.Unit,E.Newtype 1,E.Tuple 1 2,E.Struct {a=1},E.Tuple 3 2]"#;
r#"[E.Unit,E.Unit,E.Newtype 1,E.Tuple 1 2,E.Struct {a=1},E.Tuple 3 2]"#;
test_bidir(input, expected); test_bidir(input, expected);
} }