diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index cf2072e91..3034ed794 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -1,15 +1,15 @@ # Changes ## Unreleased - 2021-xx-xx +- `Resource` trait now have an associated type, `Path`, instead of the generic parameter. [#2568] +- `Resource` is now implemented for `&mut Path<_>` and `RefMut>`. [#2568] + +[#2568]: https://github.com/actix/actix-web/pull/2568 ## 0.5.0-beta.4 - 2022-01-04 - `PathDeserializer` now decodes all percent encoded characters in dynamic segments. [#2566] - Minimum supported Rust version (MSRV) is now 1.54. -- `Resource` trait now have an associated type, `Path`, instead of the generic parameter. [#2568] -- `Resource` is now implemented for `&mut Path<_>` and `RefMut>`. [#2568] - -[#2568]: https://github.com/actix/actix-web/pull/2568 [#2566]: https://github.com/actix/actix-net/pull/2566 diff --git a/actix-router/src/path.rs b/actix-router/src/path.rs index dbb02695b..fc7bb16ac 100644 --- a/actix-router/src/path.rs +++ b/actix-router/src/path.rs @@ -232,3 +232,19 @@ where &mut *self } } + +#[cfg(test)] +mod tests { + use std::cell::RefCell; + + use super::*; + + #[test] + fn deref_impls() { + let mut foo = Path::new("/foo"); + let _ = (&mut foo).resource_path(); + + let foo = RefCell::new(foo); + let _ = foo.borrow_mut().resource_path(); + } +} diff --git a/actix-router/src/resource_path.rs b/actix-router/src/resource_path.rs index 66c55a21c..00eb0927c 100644 --- a/actix-router/src/resource_path.rs +++ b/actix-router/src/resource_path.rs @@ -3,6 +3,7 @@ use crate::Path; // TODO: this trait is necessary, document it // see impl Resource for ServiceRequest pub trait Resource { + /// Type of resource's path returned in `resource_path`. type Path: ResourcePath; fn resource_path(&mut self) -> &mut Path;