These are chat archives for rust-lang/rust

Aug 2018 <-- how does Result<File> work when Result expects two type arguments.
Aug 09 2018 01:25 UTC
its a renamed type
I'm not finding anything googling for 'rust renamed type'
Is there another name it goes by?
Aug 09 2018 01:27 UTC
the result you see is actually in a different namespace
ah, by 'renamed type' you mean the type alias:
type Result<T> = Result<T, Error>;
Aug 09 2018 01:32 UTC
Sorry for my poor English
this type alias has fixed the error type
Your English is fine, my point of confusion was: I was aware of std::result::Result<T, E> ... but I didn't realize that there was a std::io::Result that bound the E=Error
David Rojas Camaggi
Aug 09 2018 01:58 UTC
hi, are syntax expressions capable of creating struct definitions from strings?
Franz Gregor
Aug 09 2018 08:43 UTC
Is there some stable equivalent to Option::transpose?
Franz Gregor
Aug 09 2018 08:48 UTC
Michal 'vorner' Vaner
Aug 09 2018 15:24 UTC
Let's say I have a TcpListener and run accept or incoming in one thread, so it is blocking. Is there a reasonable way to close and interrupt the listener from another thread?
Aug 09 2018 16:32 UTC
@vorner It is impossible to close the listned cause you need to drop it.
You can connect to it to unblock. But this approach smell

int a, b, c, d, e, f; // in C
Is there a way to write that in Rust
right now, I have to write:

a: u32, b: u32, c: u32, d: u32, e: u32, f: u32,

Andrey Lesnikov
Aug 09 2018 17:13 UTC you can use a tuple if you really want to declare multiple vars in one line
though their types still must be inferred from the context
Aug 09 2018 17:16 UTC
I have found that most times in C I end up declaring variables separately anyway. It's usually clearer what is there.
In this case, this is for the dimensions of a tensor, so it's pretty much known to be u32
Lyle Mantooth
Aug 09 2018 18:07 UTC
@qq00, you could write a macro to do that for you. But you should only do that if it actually makes it more readable/maintainable.
Aug 09 2018 18:22 UTC

My instinct would be to

struct T6(u32, u32, u32, u32, u32, u32);

impl T6 {
    fn zero() -> T6 { T6(0, 0, 0, 0, 0, 0) }

let T6(a, b, c, d, e, f) = T6::zero();

That way I'd at least always get the right number of variables.

Aug 09 2018 18:29 UTC
(Actually, I'd probably just struct T6{ a: u32, ... }. I probably want the whole set mutable if they're indices, and they make sense as a unit, and you don't really have any overhead from doing it that way AFAIK.)