Cargo fmt
This commit is contained in:
parent
52f6bd177c
commit
1579030b44
3 changed files with 60 additions and 62 deletions
|
@ -378,7 +378,9 @@ impl<'a, 'b> Term<'a, 'b> {
|
|||
/// ```
|
||||
pub fn list(&self) -> Result<Vec<Term<'a, '_>>, TypeError> {
|
||||
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")),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,7 +312,10 @@ impl<'a> T<'a> {
|
|||
buf.extend_from_slice(b"[]");
|
||||
} else if l.len() == 1 {
|
||||
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" ]");
|
||||
} else {
|
||||
let indent2 = indent + 2;
|
||||
|
@ -390,18 +393,15 @@ impl<'a> T<'a> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::debug;
|
||||
use super::*;
|
||||
use crate::debug;
|
||||
|
||||
#[test]
|
||||
fn complex1() {
|
||||
let input = seq([
|
||||
string("HELLO").unwrap(),
|
||||
string("alexhelloworld").unwrap(),
|
||||
list([
|
||||
string("dude").unwrap(),
|
||||
string("why").unwrap(),
|
||||
]),
|
||||
list([string("dude").unwrap(), string("why").unwrap()]),
|
||||
dict([
|
||||
("from", string("jxx").unwrap()),
|
||||
("subject", string("hello").unwrap()),
|
||||
|
@ -427,10 +427,7 @@ mod tests {
|
|||
let input = seq([
|
||||
string("HELLO").unwrap(),
|
||||
string("alexhelloworld").unwrap(),
|
||||
list([
|
||||
string("dude").unwrap(),
|
||||
string("why").unwrap(),
|
||||
]),
|
||||
list([string("dude").unwrap(), string("why").unwrap()]),
|
||||
dict([
|
||||
("from", string("jxx").unwrap()),
|
||||
("subject", string("hello").unwrap()),
|
||||
|
|
|
@ -11,9 +11,9 @@ pub use ser::{to_bytes, to_term, Serializer};
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::debug;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use crate::debug;
|
||||
|
||||
fn test_bidir<T: Serialize + for<'de> Deserialize<'de> + PartialEq + std::fmt::Debug>(
|
||||
input: T,
|
||||
|
@ -96,8 +96,7 @@ mod tests {
|
|||
E::Struct { a: 1 },
|
||||
E::Tuple(3, 2),
|
||||
];
|
||||
let expected =
|
||||
r#"[E.Unit,E.Unit,E.Newtype 1,E.Tuple 1 2,E.Struct {a=1},E.Tuple 3 2]"#;
|
||||
let expected = r#"[E.Unit,E.Unit,E.Newtype 1,E.Tuple 1 2,E.Struct {a=1},E.Tuple 3 2]"#;
|
||||
test_bidir(input, expected);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue