These are chat archives for rust-lang/rust

20th
Dec 2018
Kelly Thomas Kline
@kellytk
Dec 20 2018 00:24
bool should have a toggle method IMHO
Kelly Thomas Kline
@kellytk
Dec 20 2018 00:48
Associated function rather
Michal 'vorner' Vaner
@vorner
Dec 20 2018 07:07
@kellytk It's not directly toggle, but b = !b seem short enough, doesn't it?
Kelly Thomas Kline
@kellytk
Dec 20 2018 07:23
Thanks @vorner that's a good alternative
Michal 'vorner' Vaner
@vorner
Dec 20 2018 12:18
Did anything change about the place where rust packages/installers appear? The archive linked from here is a dead link: https://forge.rust-lang.org/other-installation-methods.html#standalone. Any idea into which repo to report such a thing?
Yoandy Rodriguez Martinez
@yorodm
Dec 20 2018 19:51
hello
Has anyone used the pom crate?
David O'Connor
@David-OConnor
Dec 20 2018 20:01

Does anyone know how to build a vec of &strs from a numerical range? eg:

let nums: Vec<&str> = (0..10).into_iter().map(|v| &(v.to_string())).collect();

Results in the error:

 collection of type `std::vec::Vec<&str>` cannot be built from `std::iter::Iterator<Item=&std::string::String>`
Yoandy Rodriguez Martinez
@yorodm
Dec 20 2018 20:07
Can anyone please tell me why am I getting the error message:std::convert::From<std::vec::Vec<u8>> is not implemented for std::string::String
Zakarum
@omni-viral
Dec 20 2018 20:23
@David-OConnor &str only borrows. The string should live somewhere
So to convert String to &str without relying on deref-coercion (which failed in your case) call as_str()
But then you will hit lifetime issue
So you have to do let nums: Vec<String> = (0..10).into_iter().map(|v| v.to_string()).collect(); let nums: Vec<&str> = nums.iter().map(String::as_str).collect();
David O'Connor
@David-OConnor
Dec 20 2018 20:40
Thanks a lot!
Zakarum
@omni-viral
Dec 20 2018 21:36
You're welcome