1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-27 16:29:02 +02:00

service trait takes shared self reference (#247)

This commit is contained in:
fakeshadow
2021-01-22 19:06:22 -08:00
committed by GitHub
parent 874e5f2e50
commit 636cef8868
27 changed files with 225 additions and 219 deletions

View File

@ -1,6 +1,9 @@
# Changes
## Unreleased - 2021-xx-xx
* Add `Router::recognize_checked` [#247]
[#247]: https://github.com/actix/actix-net/pull/247
## 0.2.6 - 2021-01-09

View File

@ -45,6 +45,24 @@ impl<T, U> Router<T, U> {
None
}
pub fn recognize_checked<R, P, F>(
&self,
resource: &mut R,
check: F,
) -> Option<(&T, ResourceId)>
where
F: Fn(&R, &Option<U>) -> bool,
R: Resource<P>,
P: ResourcePath,
{
for item in self.0.iter() {
if item.0.match_path_checked(resource, &check, &item.2) {
return Some((&item.1, ResourceId(item.0.id())));
}
}
None
}
pub fn recognize_mut_checked<R, P, F>(
&mut self,
resource: &mut R,