mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-26 06:57:43 +02:00
apply standard formatting
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
fn compare_quoters(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("Compare Quoters");
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use serde::de::{self, Deserializer, Error as DeError, Visitor};
|
||||
use serde::forward_to_deserialize_any;
|
||||
use serde::{
|
||||
de::{self, Deserializer, Error as DeError, Visitor},
|
||||
forward_to_deserialize_any,
|
||||
};
|
||||
|
||||
use crate::path::{Path, PathIter};
|
||||
use crate::{Quoter, ResourcePath};
|
||||
use crate::{
|
||||
path::{Path, PathIter},
|
||||
Quoter, ResourcePath,
|
||||
};
|
||||
|
||||
thread_local! {
|
||||
static FULL_QUOTER: Quoter = Quoter::new(b"", b"");
|
||||
@ -486,11 +490,7 @@ impl<'de> de::VariantAccess<'de> for UnitVariant {
|
||||
Err(de::value::Error::custom("not supported"))
|
||||
}
|
||||
|
||||
fn struct_variant<V>(
|
||||
self,
|
||||
_: &'static [&'static str],
|
||||
_: V,
|
||||
) -> Result<V::Value, Self::Error>
|
||||
fn struct_variant<V>(self, _: &'static [&'static str], _: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: Visitor<'de>,
|
||||
{
|
||||
@ -503,9 +503,7 @@ mod tests {
|
||||
use serde::{de, Deserialize};
|
||||
|
||||
use super::*;
|
||||
use crate::path::Path;
|
||||
use crate::router::Router;
|
||||
use crate::ResourceDef;
|
||||
use crate::{path::Path, router::Router, ResourceDef};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct MyStruct {
|
||||
@ -572,13 +570,11 @@ mod tests {
|
||||
assert_eq!(s.key, "name");
|
||||
assert_eq!(s.value, 32);
|
||||
|
||||
let s: (String, u8) =
|
||||
de::Deserialize::deserialize(PathDeserializer::new(&path)).unwrap();
|
||||
let s: (String, u8) = de::Deserialize::deserialize(PathDeserializer::new(&path)).unwrap();
|
||||
assert_eq!(s.0, "name");
|
||||
assert_eq!(s.1, 32);
|
||||
|
||||
let res: Vec<String> =
|
||||
de::Deserialize::deserialize(PathDeserializer::new(&path)).unwrap();
|
||||
let res: Vec<String> = de::Deserialize::deserialize(PathDeserializer::new(&path)).unwrap();
|
||||
assert_eq!(res[0], "name".to_owned());
|
||||
assert_eq!(res[1], "32".to_owned());
|
||||
}
|
||||
|
@ -18,13 +18,14 @@ mod router;
|
||||
#[cfg(feature = "http")]
|
||||
mod url;
|
||||
|
||||
pub use self::de::PathDeserializer;
|
||||
pub use self::path::Path;
|
||||
pub use self::pattern::{IntoPatterns, Patterns};
|
||||
pub use self::quoter::Quoter;
|
||||
pub use self::resource::ResourceDef;
|
||||
pub use self::resource_path::{Resource, ResourcePath};
|
||||
pub use self::router::{ResourceId, Router, RouterBuilder};
|
||||
|
||||
#[cfg(feature = "http")]
|
||||
pub use self::url::Url;
|
||||
pub use self::{
|
||||
de::PathDeserializer,
|
||||
path::Path,
|
||||
pattern::{IntoPatterns, Patterns},
|
||||
quoter::Quoter,
|
||||
resource::ResourceDef,
|
||||
resource_path::{Resource, ResourcePath},
|
||||
router::{ResourceId, Router, RouterBuilder},
|
||||
};
|
||||
|
@ -1,5 +1,7 @@
|
||||
use std::borrow::Cow;
|
||||
use std::ops::{DerefMut, Index};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
ops::{DerefMut, Index},
|
||||
};
|
||||
|
||||
use serde::de;
|
||||
|
||||
|
@ -1741,9 +1741,7 @@ mod tests {
|
||||
ResourceDef::new("/{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h}/{i}/{j}/{k}/{l}/{m}/{n}/{o}/{p}");
|
||||
|
||||
// panics
|
||||
ResourceDef::new(
|
||||
"/{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h}/{i}/{j}/{k}/{l}/{m}/{n}/{o}/{p}/{q}",
|
||||
);
|
||||
ResourceDef::new("/{a}/{b}/{c}/{d}/{e}/{f}/{g}/{h}/{i}/{j}/{k}/{l}/{m}/{n}/{o}/{p}/{q}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -117,11 +117,7 @@ where
|
||||
U: Default,
|
||||
{
|
||||
/// Registers resource for specified path.
|
||||
pub fn path(
|
||||
&mut self,
|
||||
path: impl IntoPatterns,
|
||||
val: T,
|
||||
) -> (&mut ResourceDef, &mut T, &mut U) {
|
||||
pub fn path(&mut self, path: impl IntoPatterns, val: T) -> (&mut ResourceDef, &mut T, &mut U) {
|
||||
self.push(ResourceDef::new(path), val, U::default())
|
||||
}
|
||||
|
||||
@ -142,8 +138,10 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::path::Path;
|
||||
use crate::router::{ResourceId, Router};
|
||||
use crate::{
|
||||
path::Path,
|
||||
router::{ResourceId, Router},
|
||||
};
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
#[test]
|
||||
|
@ -1,6 +1,4 @@
|
||||
use crate::ResourcePath;
|
||||
|
||||
use crate::Quoter;
|
||||
use crate::{Quoter, ResourcePath};
|
||||
|
||||
thread_local! {
|
||||
static DEFAULT_QUOTER: Quoter = Quoter::new(b"", b"%/+");
|
||||
|
Reference in New Issue
Block a user