These are chat archives for rust-lang/rust

Oct 2017
Oct 12 2017 03:54
Hey! What's the enigmatic rust way to automatically cast any type of unsigned int to a usize? Here's what I've been trying: pub fn encode<T: ?Sized + AsRef<[usize]>>(num: &T) -> String
Oct 12 2017 05:30
@kieraneglin T: AsRef<[usize]> means there are slice of usize somewhere in T. If you want to convert single integer into usize you may want to try Into<usize>.
You can't convert slice of integers into slise of usize because they have different size
Oct 12 2017 06:37
how you construct "complex" json objects in rust?
something like
var obj = {};

obj["foo"] = { "bar" : "baz"};
I looked at serde-json but I want to construct it in a more dynamical way instead of using a string. Also a Hashmap is not practical because I need to have an abitrary number of sub levels
Michal 'vorner' Vaner
Oct 12 2017 08:29
Hello. From time to time I'm annoyed with not being able to have things like Box<std::io::Read + std::io::Write>, eg The feeling I get from the error message is that it's simply not implemented, not something decided not to have. So, if I wanted to try and implement it (and maybe fail terribly at it, but one can still hope), would I have to go through the full RFC process, or is the syntaxt „obvious“ and I could just drop an issue at github to let others know I work on it?
(I know it is not part of any bigger impl period topic, but it still is one of these small papercuts I get)
Aleksey Kladov
Oct 12 2017 08:35
@vorner I think the best place to start is to make a post on or compiler's IRC channel. I expect that this feature will require an RFC: the syntax might be obvious, but I would be surprised if there are no hidden implementation and compatibility tradeoffs hidden somewhere! :)
Michal 'vorner' Vaner
Oct 12 2017 08:38
I see. I expect to see some tradeoffs as I implement it, but I expected them to be solved through the review. Maybe a naive point of view. I'll try that IRC channel.
Denis Lisov
Oct 12 2017 09:01
@vorner For now you have to do it explicitly, yes.
Oct 12 2017 09:05
I have a Rc<Image> and the function wants &Image, so I should use &*rc?
Oct 12 2017 13:00
just &rc should work
would it not?
Oct 12 2017 13:00
Yes. I think &*rc is what you need
Dimitri Sabadie
Oct 12 2017 13:39
or deref()
or &rc if it’s smart enough