Make clippy happy

This commit is contained in:
René Kijewski 2024-08-18 01:40:12 +02:00
parent 8433e24917
commit 79873f6a17
2 changed files with 9 additions and 8 deletions

View File

@ -1,9 +1,10 @@
#[allow(clippy::module_inception)]
mod html; mod html;
use arbitrary::{Arbitrary, Unstructured}; use arbitrary::{Arbitrary, Unstructured};
use html_escape::decode_html_entities_to_string; use html_escape::decode_html_entities_to_string;
#[derive(Arbitrary, Debug)] #[derive(Arbitrary, Debug, Clone, Copy)]
pub enum Scenario<'a> { pub enum Scenario<'a> {
String(&'a str), String(&'a str),
Char(char), Char(char),
@ -19,8 +20,8 @@ impl<'a> super::Scenario<'a> for Scenario<'a> {
} }
fn run(&self) -> Result<(), Self::RunError> { fn run(&self) -> Result<(), Self::RunError> {
match self { match *self {
&Scenario::String(src) => { Scenario::String(src) => {
let mut dest = String::with_capacity(src.len()); let mut dest = String::with_capacity(src.len());
html::write_escaped_str(&mut dest, src).unwrap(); html::write_escaped_str(&mut dest, src).unwrap();
@ -28,7 +29,7 @@ impl<'a> super::Scenario<'a> for Scenario<'a> {
let unescaped = decode_html_entities_to_string(dest, &mut unescaped); let unescaped = decode_html_entities_to_string(dest, &mut unescaped);
assert_eq!(src, unescaped); assert_eq!(src, unescaped);
} }
&Scenario::Char(c) => { Scenario::Char(c) => {
let mut dest = String::with_capacity(6); let mut dest = String::with_capacity(6);
html::write_escaped_char(&mut dest, c).unwrap(); html::write_escaped_char(&mut dest, c).unwrap();

View File

@ -4,14 +4,14 @@ pub mod parser;
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
pub const TARGETS: &[( pub const TARGETS: &[(&str, TargetBuilder)] = &[
&str,
for<'a> fn(&'a [u8]) -> Result<NamedTarget<'a>, Box<dyn Error + Send + 'static>>,
)] = &[
("html", |data| NamedTarget::new::<html::Scenario>(data)), ("html", |data| NamedTarget::new::<html::Scenario>(data)),
("parser", |data| NamedTarget::new::<parser::Scenario>(data)), ("parser", |data| NamedTarget::new::<parser::Scenario>(data)),
]; ];
pub type TargetBuilder =
for<'a> fn(&'a [u8]) -> Result<NamedTarget<'a>, Box<dyn Error + Send + 'static>>;
pub trait Scenario<'a>: fmt::Debug + Sized { pub trait Scenario<'a>: fmt::Debug + Sized {
type NewError: Error + Send + 'static; type NewError: Error + Send + 'static;
type RunError: Error + Send + 'static; type RunError: Error + Send + 'static;