mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 04:35:03 +01:00
more cleanup
This commit is contained in:
parent
6d944e1265
commit
de027d9f5a
9 changed files with 46 additions and 14 deletions
|
|
@ -2,7 +2,6 @@ use crate::error::TransError;
|
|||
use amqp_core::error::ConException;
|
||||
use amqp_core::methods::{FieldValue, Method, Table};
|
||||
use rand::Rng;
|
||||
use std::collections::HashMap;
|
||||
|
||||
mod generated;
|
||||
pub mod parse_helper;
|
||||
|
|
@ -65,7 +64,9 @@ rand_random_method!(bool, u8, i8, u16, i16, u32, i32, u64, i64, f32, f64);
|
|||
impl<R: Rng> RandomMethod<R> for Table {
|
||||
fn random(rng: &mut R) -> Self {
|
||||
let len = rng.gen_range(0..3);
|
||||
HashMap::from_iter((0..len).map(|_| (String::random(rng), FieldValue::random(rng))))
|
||||
(0..len)
|
||||
.map(|_| (String::random(rng), FieldValue::random(rng)))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use nom::multi::{count, many0};
|
|||
use nom::number::complete::{f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
|
||||
use nom::number::Endianness::Big;
|
||||
use nom::Err;
|
||||
use std::collections::HashMap;
|
||||
|
||||
impl<T> nom::error::ParseError<T> for TransError {
|
||||
fn from_error_kind(_input: T, _kind: ErrorKind) -> Self {
|
||||
|
|
@ -37,7 +36,7 @@ pub fn fail_err<S: Into<String>>(msg: S) -> impl FnOnce(Err<TransError>) -> Err<
|
|||
}
|
||||
_ => vec![msg],
|
||||
},
|
||||
_ => vec![msg],
|
||||
Err::Incomplete(_) => vec![msg],
|
||||
};
|
||||
Err::Failure(ConException::SyntaxError(stack).into())
|
||||
}
|
||||
|
|
@ -133,7 +132,7 @@ pub fn table(input: &[u8]) -> IResult<'_, Table> {
|
|||
));
|
||||
}
|
||||
|
||||
let table = HashMap::from_iter(values.into_iter());
|
||||
let table = values.into_iter().collect();
|
||||
Ok((rest_input, table))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue