mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 21:22:57 +01:00
commit
28d9c6a760
@ -1,41 +0,0 @@
|
||||
environment:
|
||||
global:
|
||||
PROJECT_NAME: actix-net
|
||||
matrix:
|
||||
# Stable channel
|
||||
- TARGET: i686-pc-windows-msvc
|
||||
CHANNEL: stable
|
||||
- TARGET: x86_64-pc-windows-gnu
|
||||
CHANNEL: stable
|
||||
- TARGET: x86_64-pc-windows-msvc
|
||||
CHANNEL: stable
|
||||
# Nightly channel
|
||||
- TARGET: i686-pc-windows-msvc
|
||||
CHANNEL: nightly
|
||||
- TARGET: x86_64-pc-windows-gnu
|
||||
CHANNEL: nightly
|
||||
- TARGET: x86_64-pc-windows-msvc
|
||||
CHANNEL: nightly
|
||||
|
||||
# Install Rust and Cargo
|
||||
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
|
||||
install:
|
||||
- ps: >-
|
||||
If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
|
||||
$Env:PATH += ';C:\msys64\mingw64\bin'
|
||||
} ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
|
||||
$Env:PATH += ';C:\MinGW\bin'
|
||||
}
|
||||
- curl -sSf -o rustup-init.exe https://win.rustup.rs
|
||||
- rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y
|
||||
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
|
||||
- rustc -Vv
|
||||
- cargo -V
|
||||
|
||||
# 'cargo test' takes care of building for us, so disable Appveyor's build stage.
|
||||
build: false
|
||||
|
||||
# Equivalent to Travis' `script` phase
|
||||
test_script:
|
||||
- cargo clean
|
||||
- cargo test
|
17
.github/workflows/clippy.yml
vendored
Normal file
17
.github/workflows/clippy.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
on: pull_request
|
||||
|
||||
name: Clippy Check
|
||||
jobs:
|
||||
clippy_check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: clippy
|
||||
override: true
|
||||
- uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --all-features --all --tests
|
37
.github/workflows/macos.yml
vendored
Normal file
37
.github/workflows/macos.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
name: CI (macOS)
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version:
|
||||
- stable
|
||||
- nightly
|
||||
|
||||
name: ${{ matrix.version }} - x86_64-apple-darwin
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Install ${{ matrix.version }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.version }}-x86_64-apple-darwin
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: check build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all --all-features --no-fail-fast -- --nocapture
|
78
.github/workflows/main.yml
vendored
78
.github/workflows/main.yml
vendored
@ -1,78 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
VCPKGRS_DYNAMIC: 1
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
toolchain:
|
||||
- x86_64-pc-windows-msvc
|
||||
- x86_64-pc-windows-gnu
|
||||
- i686-pc-windows-msvc
|
||||
- x86_64-apple-darwin
|
||||
version:
|
||||
- stable
|
||||
- nightly
|
||||
include:
|
||||
- toolchain: x86_64-pc-windows-msvc
|
||||
os: windows-latest
|
||||
arch: x64
|
||||
- toolchain: x86_64-pc-windows-gnu
|
||||
os: windows-latest
|
||||
- toolchain: i686-pc-windows-msvc
|
||||
os: windows-latest
|
||||
arch: x86
|
||||
- toolchain: x86_64-apple-darwin
|
||||
os: macOS-latest
|
||||
|
||||
name: ${{ matrix.version }} - ${{ matrix.toolchain }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Install ${{ matrix.version }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.version }}-${{ matrix.toolchain }}
|
||||
default: true
|
||||
|
||||
|
||||
- name: Install OpenSSL
|
||||
if: matrix.toolchain == 'x86_64-pc-windows-msvc' || matrix.toolchain == 'i686-pc-windows-msvc'
|
||||
run: |
|
||||
vcpkg integrate install
|
||||
vcpkg install openssl:${{ matrix.arch }}-windows
|
||||
|
||||
- name: check nightly
|
||||
if: matrix.version == 'nightly'
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --benches --bins --examples --tests
|
||||
|
||||
- name: check stable
|
||||
if: matrix.version == 'stable'
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
if: matrix.toolchain != 'x86_64-pc-windows-gnu'
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all --all-features -- --nocapture
|
||||
|
||||
- name: tests on x86_64-pc-windows-gnu
|
||||
if: matrix.toolchain == 'x86_64-pc-windows-gnu'
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all -- --nocapture
|
54
.github/workflows/windows-mingw.yml
vendored
Normal file
54
.github/workflows/windows-mingw.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: CI (Windows-gnu)
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
OPENSSL_DIR: d:\a\_temp\msys\msys64\usr
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version:
|
||||
- stable
|
||||
- nightly
|
||||
|
||||
name: ${{ matrix.version }} - x86_64-pc-windows-gnu
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Install ${{ matrix.version }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.version }}-x86_64-pc-windows-gnu
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install MSYS2
|
||||
uses: numworks/setup-msys2@v1
|
||||
|
||||
- name: Install OpenSSL
|
||||
run: |
|
||||
msys2do pacman --noconfirm -S openssl-devel pkg-config
|
||||
|
||||
- name: Copy and check libs
|
||||
run: |
|
||||
Copy-Item d:\a\_temp\msys\msys64\usr\lib\libssl.dll.a d:\a\_temp\msys\msys64\usr\lib\libssl.dll
|
||||
Copy-Item d:\a\_temp\msys\msys64\usr\lib\libcrypto.dll.a d:\a\_temp\msys\msys64\usr\lib\libcrypto.dll
|
||||
Get-ChildItem d:\a\_temp\msys\msys64\usr\lib
|
||||
Get-ChildItem d:\a\_temp\msys\msys64\usr
|
||||
|
||||
- name: check build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all --all-features --no-fail-fast -- --nocapture
|
63
.github/workflows/windows.yml
vendored
Normal file
63
.github/workflows/windows.yml
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
name: CI (Windows)
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
VCPKGRS_DYNAMIC: 1
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version:
|
||||
- stable
|
||||
- nightly
|
||||
target:
|
||||
- x86_64-pc-windows-msvc
|
||||
- i686-pc-windows-msvc
|
||||
|
||||
name: ${{ matrix.version }} - ${{ matrix.target }}
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Install ${{ matrix.version }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.version }}-${{ matrix.target }}
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Install OpenSSL (x64)
|
||||
if: matrix.target == 'x86_64-pc-windows-msvc'
|
||||
run: |
|
||||
vcpkg integrate install
|
||||
vcpkg install openssl:x64-windows
|
||||
Get-ChildItem C:\vcpkg\installed\x64-windows\bin
|
||||
Get-ChildItem C:\vcpkg\installed\x64-windows\lib
|
||||
Copy-Item C:\vcpkg\installed\x64-windows\bin\libcrypto-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libcrypto.dll
|
||||
Copy-Item C:\vcpkg\installed\x64-windows\bin\libssl-1_1-x64.dll C:\vcpkg\installed\x64-windows\bin\libssl.dll
|
||||
|
||||
- name: Install OpenSSL (x86)
|
||||
if: matrix.target == 'i686-pc-windows-msvc'
|
||||
run: |
|
||||
vcpkg integrate install
|
||||
vcpkg install openssl:x86-windows
|
||||
Get-ChildItem C:\vcpkg\installed\x86-windows\bin
|
||||
Get-ChildItem C:\vcpkg\installed\x86-windows\lib
|
||||
Copy-Item C:\vcpkg\installed\x86-windows\bin\libcrypto-1_1.dll C:\vcpkg\installed\x86-windows\bin\libcrypto.dll
|
||||
Copy-Item C:\vcpkg\installed\x86-windows\bin\libssl-1_1.dll C:\vcpkg\installed\x86-windows\bin\libssl.dll
|
||||
|
||||
- name: check build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --all --bins --examples --tests
|
||||
|
||||
- name: tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all --all-features --no-fail-fast -- --nocapture
|
@ -38,7 +38,7 @@ where
|
||||
{
|
||||
pub fn service(connector: Arc<ClientConfig>) -> RustlsConnectorService<T, U> {
|
||||
RustlsConnectorService {
|
||||
connector: connector,
|
||||
connector,
|
||||
_t: PhantomData,
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ where
|
||||
// drain service responses
|
||||
match Pin::new(&mut self.rx).poll_next(cx) {
|
||||
Poll::Ready(Some(Ok(msg))) => {
|
||||
if let Err(_) = self.framed.write(msg) {
|
||||
if self.framed.write(msg).is_err() {
|
||||
return Poll::Ready(Ok(()));
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use quote::quote;
|
||||
/// println!("Hello world");
|
||||
/// }
|
||||
/// ```
|
||||
#[allow(clippy::needless_doctest_main)]
|
||||
#[proc_macro_attribute]
|
||||
#[cfg(not(test))] // Work around for rust-lang/rust#62127
|
||||
pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
|
||||
|
@ -86,7 +86,6 @@ impl Runtime {
|
||||
where
|
||||
F: Future + 'static,
|
||||
{
|
||||
let res = self.local.block_on(&mut self.rt, f);
|
||||
res
|
||||
self.local.block_on(&mut self.rt, f)
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ impl ServerBuilder {
|
||||
self.services.push(StreamNewService::create(
|
||||
name.as_ref().to_string(),
|
||||
token,
|
||||
factory.clone(),
|
||||
factory,
|
||||
addr,
|
||||
));
|
||||
self.sockets
|
||||
|
@ -91,7 +91,7 @@ impl ConfiguredService {
|
||||
|
||||
pub(super) fn stream(&mut self, token: Token, name: String, addr: net::SocketAddr) {
|
||||
self.names.insert(token, (name.clone(), addr));
|
||||
self.topics.insert(name.clone(), token);
|
||||
self.topics.insert(name, token);
|
||||
self.services.push(token);
|
||||
}
|
||||
}
|
||||
|
@ -315,6 +315,8 @@ enum WorkerState {
|
||||
impl Future for Worker {
|
||||
type Output = ();
|
||||
|
||||
// FIXME: remove this attribute
|
||||
#[allow(clippy::never_loop)]
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
// `StopWorker` message handler
|
||||
if let Poll::Ready(Some(StopCommand { graceful, result })) =
|
||||
@ -368,12 +370,9 @@ impl Future for Worker {
|
||||
Ok(false) => {
|
||||
// push connection back to queue
|
||||
if let Some(conn) = conn {
|
||||
match self.state {
|
||||
WorkerState::Unavailable(ref mut conns) => {
|
||||
if let WorkerState::Unavailable(ref mut conns) = self.state {
|
||||
conns.push(conn);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
Poll::Pending
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ fn test_bind() {
|
||||
|
||||
thread::sleep(time::Duration::from_millis(500));
|
||||
assert!(net::TcpStream::connect(addr).is_ok());
|
||||
let _ = sys.stop();
|
||||
sys.stop();
|
||||
let _ = h.join();
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ fn test_listen() {
|
||||
|
||||
thread::sleep(time::Duration::from_millis(500));
|
||||
assert!(net::TcpStream::connect(addr).is_ok());
|
||||
let _ = sys.stop();
|
||||
sys.stop();
|
||||
let _ = h.join();
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ fn test_start() {
|
||||
assert!(net::TcpStream::connect(addr).is_err());
|
||||
|
||||
thread::sleep(time::Duration::from_millis(100));
|
||||
let _ = sys.stop();
|
||||
sys.stop();
|
||||
let _ = h.join();
|
||||
}
|
||||
|
||||
@ -178,6 +178,6 @@ fn test_configure() {
|
||||
assert!(net::TcpStream::connect(addr2).is_ok());
|
||||
assert!(net::TcpStream::connect(addr3).is_ok());
|
||||
assert_eq!(num.load(Relaxed), 1);
|
||||
let _ = sys.stop();
|
||||
sys.stop();
|
||||
let _ = h.join();
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ mod tests {
|
||||
let mut srv = pipeline(Srv1(cnt.clone())).and_then(Srv2(cnt));
|
||||
let res = srv.call("srv1").await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), (("srv1", "srv2")));
|
||||
assert_eq!(res.unwrap(), ("srv1", "srv2"));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
|
@ -290,6 +290,7 @@ mod tests {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
#[allow(clippy::unit_arg)]
|
||||
fn call(&mut self, req: Self::Request) -> Self::Future {
|
||||
ok(req)
|
||||
}
|
||||
@ -297,7 +298,7 @@ mod tests {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service() {
|
||||
let mut srv = pipeline(|r: &'static str| ok(r))
|
||||
let mut srv = pipeline(ok)
|
||||
.and_then_apply_fn(Srv, |req: &'static str, s| {
|
||||
s.call(()).map_ok(move |res| (req, res))
|
||||
});
|
||||
@ -311,7 +312,7 @@ mod tests {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_service_factory() {
|
||||
let new_srv = pipeline_factory(|| ok::<_, ()>(fn_service(|r: &'static str| ok(r))))
|
||||
let new_srv = pipeline_factory(|| ok::<_, ()>(fn_service(ok)))
|
||||
.and_then_apply_fn(
|
||||
|| ok(Srv),
|
||||
|req: &'static str, s| s.call(()).map_ok(move |res| (req, res)),
|
||||
|
@ -233,8 +233,8 @@ mod tests {
|
||||
let mut srv = pipeline(apply_fn(Srv, |req: &'static str, srv| {
|
||||
let fut = srv.call(());
|
||||
async move {
|
||||
let res = fut.await.unwrap();
|
||||
Ok((req, res))
|
||||
fut.await.unwrap();
|
||||
Ok((req, ()))
|
||||
}
|
||||
}));
|
||||
|
||||
@ -242,7 +242,7 @@ mod tests {
|
||||
|
||||
let res = srv.call("srv").await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), (("srv", ())));
|
||||
assert_eq!(res.unwrap(), ("srv", ()));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
@ -252,8 +252,8 @@ mod tests {
|
||||
|req: &'static str, srv| {
|
||||
let fut = srv.call(());
|
||||
async move {
|
||||
let res = fut.await.unwrap();
|
||||
Ok((req, res))
|
||||
fut.await.unwrap();
|
||||
Ok((req, ()))
|
||||
}
|
||||
},
|
||||
));
|
||||
@ -264,6 +264,6 @@ mod tests {
|
||||
|
||||
let res = srv.call("srv").await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), (("srv", ())));
|
||||
assert_eq!(res.unwrap(), ("srv", ()));
|
||||
}
|
||||
}
|
||||
|
@ -305,11 +305,11 @@ mod tests {
|
||||
|
||||
let res = srv.call(Ok("srv1")).await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), (("srv1", "ok")));
|
||||
assert_eq!(res.unwrap(), ("srv1", "ok"));
|
||||
|
||||
let res = srv.call(Err("srv")).await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), (("srv2", "err")));
|
||||
assert_eq!(res.unwrap(), ("srv2", "err"));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
@ -321,10 +321,10 @@ mod tests {
|
||||
let mut srv = factory.new_service(&()).await.unwrap();
|
||||
let res = srv.call(Ok("srv1")).await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), (("srv1", "ok")));
|
||||
assert_eq!(res.unwrap(), ("srv1", "ok"));
|
||||
|
||||
let res = srv.call(Err("srv")).await;
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(res.unwrap(), (("srv2", "err")));
|
||||
assert_eq!(res.unwrap(), ("srv2", "err"));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Various helpers for Actix applications to use during testing.
|
||||
#![deny(rust_2018_idioms, warnings)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::type_complexity, clippy::needless_doctest_main)]
|
||||
|
||||
use std::sync::mpsc;
|
||||
use std::{net, thread};
|
||||
|
@ -107,7 +107,7 @@ mod tests {
|
||||
Poll::Pending
|
||||
);
|
||||
cond.notify();
|
||||
assert_eq!(waiter.await, ());
|
||||
waiter.await;
|
||||
|
||||
let mut waiter = cond.wait();
|
||||
assert_eq!(
|
||||
@ -121,7 +121,7 @@ mod tests {
|
||||
);
|
||||
|
||||
drop(cond);
|
||||
assert_eq!(waiter.await, ());
|
||||
assert_eq!(waiter2.await, ());
|
||||
waiter.await;
|
||||
waiter2.await;
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ mod tests {
|
||||
let rx2 = rx2;
|
||||
let rx3 = rx3;
|
||||
let tx_stop = tx_stop;
|
||||
let _ = actix_rt::System::new("test").block_on(async {
|
||||
actix_rt::System::new("test").block_on(async {
|
||||
let mut srv = InOrderService::new(Srv);
|
||||
|
||||
let _ = lazy(|cx| srv.poll_ready(cx)).await;
|
||||
@ -251,7 +251,7 @@ mod tests {
|
||||
let res3 = srv.call(rx3);
|
||||
|
||||
actix_rt::spawn(async move {
|
||||
let _ = poll_fn(|cx| {
|
||||
poll_fn(|cx| {
|
||||
let _ = srv.poll_ready(cx);
|
||||
Poll::<()>::Pending
|
||||
})
|
||||
|
@ -69,7 +69,7 @@ impl<'a> IntoPattern for &'a str {
|
||||
}
|
||||
|
||||
fn patterns(&self) -> Vec<String> {
|
||||
vec![self.to_string()]
|
||||
vec![(*self).to_string()]
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ impl<T: AsRef<str>> IntoPattern for Vec<T> {
|
||||
}
|
||||
|
||||
fn patterns(&self) -> Vec<String> {
|
||||
self.into_iter().map(|v| v.as_ref().to_string()).collect()
|
||||
self.iter().map(|v| v.as_ref().to_string()).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ impl ResourceDef {
|
||||
return false;
|
||||
}
|
||||
for idx in 0..idx {
|
||||
path.add(names[idx].clone(), segments[idx]);
|
||||
path.add(names[idx], segments[idx]);
|
||||
}
|
||||
path.skip((pos + len) as u16);
|
||||
true
|
||||
@ -326,7 +326,7 @@ impl ResourceDef {
|
||||
return false;
|
||||
}
|
||||
for idx in 0..idx {
|
||||
path.add(names[idx].clone(), segments[idx]);
|
||||
path.add(names[idx], segments[idx]);
|
||||
}
|
||||
path.skip((pos + len) as u16);
|
||||
true
|
||||
@ -413,7 +413,7 @@ impl ResourceDef {
|
||||
|
||||
let path = res.resource_path();
|
||||
for idx in 0..idx {
|
||||
path.add(names[idx].clone(), segments[idx]);
|
||||
path.add(names[idx], segments[idx]);
|
||||
}
|
||||
path.skip((pos + len) as u16);
|
||||
true
|
||||
@ -452,7 +452,7 @@ impl ResourceDef {
|
||||
|
||||
let path = res.resource_path();
|
||||
for idx in 0..idx {
|
||||
path.add(names[idx].clone(), segments[idx]);
|
||||
path.add(names[idx], segments[idx]);
|
||||
}
|
||||
path.skip((pos + len) as u16);
|
||||
true
|
||||
@ -734,6 +734,7 @@ mod tests {
|
||||
assert_eq!(path.get("id").unwrap(), "012345");
|
||||
}
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
#[test]
|
||||
fn test_dynamic_set() {
|
||||
let re = ResourceDef::new(vec![
|
||||
@ -899,31 +900,31 @@ mod tests {
|
||||
fn test_resource_path() {
|
||||
let mut s = String::new();
|
||||
let resource = ResourceDef::new("/user/{item1}/test");
|
||||
assert!(resource.resource_path(&mut s, &mut (&["user1"]).into_iter()));
|
||||
assert!(resource.resource_path(&mut s, &mut (&["user1"]).iter()));
|
||||
assert_eq!(s, "/user/user1/test");
|
||||
|
||||
let mut s = String::new();
|
||||
let resource = ResourceDef::new("/user/{item1}/{item2}/test");
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).into_iter()));
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).iter()));
|
||||
assert_eq!(s, "/user/item/item2/test");
|
||||
|
||||
let mut s = String::new();
|
||||
let resource = ResourceDef::new("/user/{item1}/{item2}");
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).into_iter()));
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).iter()));
|
||||
assert_eq!(s, "/user/item/item2");
|
||||
|
||||
let mut s = String::new();
|
||||
let resource = ResourceDef::new("/user/{item1}/{item2}/");
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).into_iter()));
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).iter()));
|
||||
assert_eq!(s, "/user/item/item2/");
|
||||
|
||||
let mut s = String::new();
|
||||
assert!(!resource.resource_path(&mut s, &mut (&["item"]).into_iter()));
|
||||
assert!(!resource.resource_path(&mut s, &mut (&["item"]).iter()));
|
||||
|
||||
let mut s = String::new();
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).into_iter()));
|
||||
assert!(resource.resource_path(&mut s, &mut (&["item", "item2"]).iter()));
|
||||
assert_eq!(s, "/user/item/item2/");
|
||||
assert!(!resource.resource_path(&mut s, &mut (&["item"]).into_iter()));
|
||||
assert!(!resource.resource_path(&mut s, &mut (&["item"]).iter()));
|
||||
|
||||
let mut s = String::new();
|
||||
assert!(resource.resource_path(&mut s, &mut vec!["item", "item2"].into_iter()));
|
||||
|
@ -104,6 +104,7 @@ mod tests {
|
||||
use crate::path::Path;
|
||||
use crate::router::{ResourceId, Router};
|
||||
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
#[test]
|
||||
fn test_recognizer_1() {
|
||||
let mut router = Router::<usize>::build();
|
||||
|
@ -204,7 +204,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_from_static_str() {
|
||||
const _S: ByteString = ByteString::from_static("hello");
|
||||
static _S: ByteString = ByteString::from_static("hello");
|
||||
let _ = ByteString::from_static("str");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user