Closed NickeZ closed 5 years ago
That seems like a false-positive from clippy, and appears to have been fixed at some point, I added the below test and didn't get any warning from it:
#[test]
fn box_clippy() {
let mut router = Router::new();
router.add("/foo/:/bar", Box::new("test"));
let m: Match<&Box<&str>> = router.recognize("/foo/test/bar").unwrap();
assert_eq!(**m.handler, "test");
assert_eq!(m.params, Params::new());
}
When I use
route-recognizer
like you use it inconduit-router
clippy complaints that&Handler
always is better than&Box<Handler>
.When you store the Router destinations in a box, the return type of
recognize()
ends up being&'a Box<Handler>
.I added a
HeapRouter
that takes boxed things and returns references to the inner type instead. Is this a good way to deal with this lint or do you suggest some other way?https://github.com/NickeZ/route-recognizer.rs/commit/66e928ee627d9e26e61fca004296ec3ea971ae36