I was trying to have parse() return slices from the parser like you normally would. Some clarity in the docs as to if references with lifetimes are possible above the call to parse(). I switched to returning owned values, so I'm confused as to where this lifetime is coming from.
error[E0308]: mismatched types
--> crates/tor-socksproto/src/handshake.rs:38:11
|
38 | i.parse(alt((FirstAction::s4, FirstAction::s5)))
| ^^^^^ one type is more general than the other
|
::: /home/cheako/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-7.1.0/src/branch/mod.rs:73:6
|
73 | ) -> impl FnMut(I) -> IResult<I, O, E> {
| ---------------------------------
| |
| the expected opaque type
| the found opaque type
|
= note: expected associated type `<impl FnMut<(&[u8],)> as FnOnce<(&[u8],)>>::Output`
found associated type `<impl FnMut<(&[u8],)> as FnOnce<(&'a [u8],)>>::Output`
error[E0308]: mismatched types
--> crates/tor-socksproto/src/handshake.rs:90:23
|
90 | i.parse(SecondAction::s5_uname)
| ^^^^^ one type is more general than the other
|
= note: expected associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], SecondAction), nom::Err<nom::error::Error<&'r [u8]>>> {SecondAction::s5_uname} as FnOnce<(&[u8],)>>::Output`
found associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], SecondAction), nom::Err<nom::error::Error<&'r [u8]>>> {SecondAction::s5_uname} as FnOnce<(&'a [u8],)>>::Output`
error[E0308]: mismatched types
--> crates/tor-socksproto/src/handshake.rs:137:18
|
137 | .parse(ThirdAction::s4)
| ^^^^^ one type is more general than the other
|
= note: expected associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], SocksRequest), nom::Err<nom::error::Error<&'r [u8]>>> {ThirdAction::s4} as FnOnce<(&[u8],)>>::Output`
found associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], SocksRequest), nom::Err<nom::error::Error<&'r [u8]>>> {ThirdAction::s4} as FnOnce<(&'a [u8],)>>::Output`
error[E0308]: mismatched types
--> crates/tor-socksproto/src/handshake.rs:142:22
|
142 | .parse(ThirdAction::s5)
| ^^^^^ one type is more general than the other
|
= note: expected associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], (impls::SocksCmd, SocksAddr, u16)), nom::Err<nom::error::Error<&'r [u8]>>> {ThirdAction::s5} as FnOnce<(&[u8],)>>::Output`
found associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], (impls::SocksCmd, SocksAddr, u16)), nom::Err<nom::error::Error<&'r [u8]>>> {ThirdAction::s5} as FnOnce<(&'a [u8],)>>::Output`
error[E0308]: mismatched types
--> crates/tor-socksproto/src/handshake.rs:156:22
|
156 | .parse(ThirdAction::s5)
| ^^^^^ one type is more general than the other
|
= note: expected associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], (impls::SocksCmd, SocksAddr, u16)), nom::Err<nom::error::Error<&'r [u8]>>> {ThirdAction::s5} as FnOnce<(&[u8],)>>::Output`
found associated type `<for<'r> fn(&'r [u8]) -> std::result::Result<(&'r [u8], (impls::SocksCmd, SocksAddr, u16)), nom::Err<nom::error::Error<&'r [u8]>>> {ThirdAction::s5} as FnOnce<(&'a [u8],)>>::Output`
For more information about this error, try `rustc --explain E0308`.
I was trying to have
parse()
return slices from the parser like you normally would. Some clarity in the docs as to if references with lifetimes are possible above the call toparse()
. I switched to returning owned values, so I'm confused as to where this lifetime is coming from.https://gitlab.torproject.org/cheako/arti/-/blob/1b1c61b48a8f30e6911a954fa358b657462b6e14/crates/tor-socksproto/src/handshake.rs#L35-68