These are chat archives for rust-lang/rust

19th
Apr 2019
bodqhrohro
@bodqhrohro
Apr 19 06:18
How does Rust implicitly convert string to Path? I don't see any from_ method or kinda that in Path documentation. Does it implicitly call the constructor for that?
Denis Lisov
@tanriol
Apr 19 08:08
@chmln How about use futures::io::AsyncRead;?
@bodqhrohro Not sure about "implicitly", but there's at least impl AsRef<Path> for str and impl AsRef<Path> for String
Zakarum
@omni-viral
Apr 19 11:11
@bodqhrohro Typically functions takes impl AsRef<Path> instead of &Path
Chris Hanks
@chanks
Apr 19 21:40
I'm new to Rust and trying to build a simple app that uses Fluent-rs to manage localizations. Right now I'm trying to write a function that returns a HashMap of FluentBundle structs indexed by the locale they're for. So my function signature looks like pub fn bundles_by_locale() -> HashMap<String, FluentBundle + 'static> {, which seems right, but the compiler is complaining expected trait, found struct FluentBundle and help: a crate with a similar name exists: fluent_bundle. I guess the compiler wants me to replace FluentBundle in the function signature with a trait of some kind, but I'm not sure why or which one I'd use...?
Denis Lisov
@tanriol
Apr 19 22:41
The correct syntax would be FluentBundle<'static> as this is a lifetime parameter, not an additional constraint to a trait.
Chris Hanks
@chanks
Apr 19 22:51
Ah, that did it! Thanks @tanriol!