These are chat archives for rust-lang/rust

8th
Jul 2017
Syed Faraaz Ahmad
@faraazahmad
Jul 08 2017 06:48
hey folks!
in the function declaration
fn foo() {}
and
fn bar() -> ! {}
why is the latter used?
Arthur
@Biacode
Jul 08 2017 06:50
I believe it's means it will return error
Like Nothing in Scala
Syed Faraaz Ahmad
@faraazahmad
Jul 08 2017 06:51
is there a way to check it?
im so new to rust
Arthur
@Biacode
Jul 08 2017 06:53
I can try to help/send docks when I will be at my PC
Syed Faraaz Ahmad
@faraazahmad
Jul 08 2017 06:53
this subreddit says ! indicates that the function never returns
Arthur
@Biacode
Jul 08 2017 06:54
Yeah, like panic! which is error
My sentence about return error is quite wrong
for instance you can use it when you want to call a function which will exit the application
or call a function which should and will panic etc...
Syed Faraaz Ahmad
@faraazahmad
Jul 08 2017 06:58
ah
thanks
Arthur
@Biacode
Jul 08 2017 06:58
Welcome :thumbsup:
Jeshwanth Kumar N K
@Jeshwanth
Jul 08 2017 09:56
Hi, I used vector in C++ STL and rust. And felt rust has many features using vector than C++. How come these possible, why not C++ STL doesn't implement those.. ?
I understand it's a design constraint.
Arthur
@Biacode
Jul 08 2017 10:00
I think partially it's about who makes standards. In C++ there is committed for that purpose. In rust the community can be part of any rfc/design making, and it's makes rust amazing as it is
Daan Rijks
@ijks
Jul 08 2017 10:02
Not familiar with C++, what features does Vec have that std::vector doesn't?
Arthur
@Biacode
Jul 08 2017 10:03
At least map, flatmap, operations with lambdas etc ...
Even though if I correct C++ has lambdas
I mean C++ 11
You can find those operations in boost and not in the std
Jeshwanth Kumar N K
@Jeshwanth
Jul 08 2017 17:31
Is it available for rust ? Any stable UI framework in rust ?
Byte
@HeapUnderfl0w
Jul 08 2017 18:04
@Jeshwanth maybe this does the trick for you ? https://github.com/PistonDevelopers/conrod
As an UI framework (its more an lib but meh.)
Dale Wijnand
@dwijnand
Jul 08 2017 18:20
Is it possible to bring all the struct fields of a variable into scope?
ie.
let c = Foo { x: 1 };
use c::*;
Jeshwanth Kumar N K
@Jeshwanth
Jul 08 2017 18:43
Thanks @HeapUnderfl0w I will have a look
Daan Rijks
@ijks
Jul 08 2017 19:08

@dwijnand You could do:

let Foo { x } = c;

If Foo has other fields, but you want to bring only x in scope, you can do:

let Foo { x, .. } = c;
Dale Wijnand
@dwijnand
Jul 08 2017 19:09
Is there syntax to introduce all the fields?
ala
let Foo { * } = c;
Ilya Bogdanov
@vitvakatu
Jul 08 2017 19:10
Why do you need that?
You'll need exact variable names anyway
Daan Rijks
@ijks
Jul 08 2017 19:11
Doesn't look like it, no. https://is.gd/5GGo4I
I guess it's a matter of explicit over implicit.
Dale Wijnand
@dwijnand
Jul 08 2017 19:12
Ok. Well 1 decontructing for all fields, explicitly, still beats 1-per-field. Thank you.
@vitvakatu Just to remove the maintaince. As I add fields to Foo and use them I don't need to declare them explicitly.
Ilya Bogdanov
@vitvakatu
Jul 08 2017 19:14
It's awful syntax if you have smth like:
struct Foo { x: i32 }
let c = Foo { x: 30 };
... multiple lines of code ...
let x = ...
... multiple lines of code ...

let Foo { * } = c;
samoylovfp
@samoylovfp
Jul 08 2017 21:17
Hi! Does anyone want to to check if this was reported? ICE on nightly in impl Trait definition
https://is.gd/rOP5eK
Daan Rijks
@ijks
Jul 08 2017 22:30
@samoylovfp Looks like this one: rust-lang/rust#43073