These are chat archives for Ogeon/rustful

29th
Sep 2015
Vincent Prouillet
@Keats
Sep 29 2015 16:30
hey, how to have a path have several http methods?
    let mut router = TreeRouter::new();
    router.insert(Get, &"passwords", get_passwords);
    router.insert(Post, &"passwords", create_password);
fails with
 expected `fn(rustful::context::Context<'_, '_, '_>, rustful::response::Response<'_, '_>) {get_passwords}`,
    found `fn(rustful::context::Context<'_, '_, '_>, rustful::response::Response<'_, '_>) {create_password}`
Erik Hedvall
@Ogeon
Sep 29 2015 16:32
Functions in Rust have distinct types, so you have to cast them to fn(Context, Response). I think this should be enough:
let mut router = TreeRouter::new();
router.insert(Get,  &"passwords",  get_passwords as fn(Context, Response));
router.insert(Post,  &"passwords",  create_password);
Vincent Prouillet
@Keats
Sep 29 2015 16:34
it works cheers
Erik Hedvall
@Ogeon
Sep 29 2015 16:34
:+1: