Fix clippy errors.
This commit is contained in:
parent
7223e08df3
commit
b46fae331b
@ -6,9 +6,9 @@ pub(crate) type Res<T, U> = IResult<T, U, CustomError>;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CustomError {
|
pub enum CustomError {
|
||||||
Static(&'static str),
|
Static(#[allow(dead_code)] &'static str),
|
||||||
IO(std::io::Error),
|
IO(#[allow(dead_code)] std::io::Error),
|
||||||
Parser(ErrorKind),
|
Parser(#[allow(dead_code)] ErrorKind),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: std::fmt::Debug> ParseError<I> for CustomError {
|
impl<I: std::fmt::Debug> ParseError<I> for CustomError {
|
||||||
|
@ -106,7 +106,6 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::context::bind_context;
|
use crate::context::bind_context;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::context::ContextElement;
|
|
||||||
use crate::context::GlobalSettings;
|
use crate::context::GlobalSettings;
|
||||||
use crate::context::List;
|
use crate::context::List;
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ fn _heading<'b, 'g, 'r, 's>(
|
|||||||
// If the section has a planning then the timestamp values are copied to the heading.
|
// If the section has a planning then the timestamp values are copied to the heading.
|
||||||
if let DocumentElement::Section(inner_section) = §ion {
|
if let DocumentElement::Section(inner_section) = §ion {
|
||||||
if let Some(Element::Planning(planning)) = inner_section.children.first() {
|
if let Some(Element::Planning(planning)) = inner_section.children.first() {
|
||||||
scheduled = planning.scheduled.clone();
|
scheduled.clone_from(&planning.scheduled);
|
||||||
deadline = planning.deadline.clone();
|
deadline.clone_from(&planning.deadline);
|
||||||
closed = planning.closed.clone();
|
closed.clone_from(&planning.closed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
children.insert(0, section);
|
children.insert(0, section);
|
||||||
|
@ -224,7 +224,6 @@ mod tests {
|
|||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::parser::OrgSource;
|
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_affiliated_keyword(b: &mut Bencher) {
|
fn bench_affiliated_keyword(b: &mut Bencher) {
|
||||||
|
@ -175,9 +175,7 @@ pub(crate) trait RematchObject<'x> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::context::Context;
|
|
||||||
use crate::context::GlobalSettings;
|
use crate::context::GlobalSettings;
|
||||||
use crate::context::List;
|
|
||||||
use crate::parser::element_parser::element;
|
use crate::parser::element_parser::element;
|
||||||
use crate::types::Bold;
|
use crate::types::Bold;
|
||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
|
@ -6,7 +6,6 @@ mod greater_element;
|
|||||||
mod lesser_element;
|
mod lesser_element;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod object;
|
mod object;
|
||||||
mod remove_trailing;
|
|
||||||
mod standard_properties;
|
mod standard_properties;
|
||||||
mod util;
|
mod util;
|
||||||
pub use affiliated_keyword::AffiliatedKeyword;
|
pub use affiliated_keyword::AffiliatedKeyword;
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
pub(crate) trait RemoveTrailing: Iterator + Sized {
|
|
||||||
fn remove_trailing<R: Into<usize>>(self, amount_to_remove: R) -> RemoveTrailingIter<Self>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I> RemoveTrailing for I
|
|
||||||
where
|
|
||||||
I: Iterator,
|
|
||||||
{
|
|
||||||
fn remove_trailing<R: Into<usize>>(self, amount_to_remove: R) -> RemoveTrailingIter<Self> {
|
|
||||||
RemoveTrailingIter {
|
|
||||||
inner: self,
|
|
||||||
buffer: Vec::new(),
|
|
||||||
next_to_pop: 0,
|
|
||||||
amount_to_remove: amount_to_remove.into(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct RemoveTrailingIter<I: Iterator> {
|
|
||||||
inner: I,
|
|
||||||
buffer: Vec<I::Item>,
|
|
||||||
next_to_pop: usize,
|
|
||||||
amount_to_remove: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I: Iterator> Iterator for RemoveTrailingIter<I> {
|
|
||||||
type Item = I::Item;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
if self.buffer.len() < self.amount_to_remove {
|
|
||||||
self.buffer.reserve_exact(self.amount_to_remove);
|
|
||||||
}
|
|
||||||
while self.buffer.len() < self.amount_to_remove {
|
|
||||||
if let Some(elem) = self.inner.next() {
|
|
||||||
self.buffer.push(elem);
|
|
||||||
} else {
|
|
||||||
// The inner was smaller than amount_to_remove, so never return anything.
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let new_value = self.inner.next();
|
|
||||||
if self.amount_to_remove == 0 {
|
|
||||||
return new_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(new_value) = new_value {
|
|
||||||
let ret = std::mem::replace(&mut self.buffer[self.next_to_pop], new_value);
|
|
||||||
self.next_to_pop = (self.next_to_pop + 1) % self.amount_to_remove;
|
|
||||||
Some(ret)
|
|
||||||
} else {
|
|
||||||
// We have exactly the amount in the buffer than we wanted to cut off, so stop returning values.
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user