These are chat archives for rust-lang/rust

19th
Jan 2018
Jacob Flores
@flores-jacob
Jan 19 2018 06:11
Hi Rust! I'm new to the language (and contributing to OSS for that matter) and I was wondering if there's a way I can contribute, and at the same time speed up learning. I've only been through up to Chapter 4 (ownership) of the Rust Book (2nd ed), but I was hoping there were something I can get involved with.
Michal 'vorner' Vaner
@vorner
Jan 19 2018 08:12
@flores-jacob You might be interested in this presentation: https://www.youtube.com/watch?v=Abu2BNixXak. It probably answers many of your questions about contributing.
cryptopatrick
@cryptopatrick
Jan 19 2018 13:14
Hi! I'm looking for some feedback from people who have coded in Pythong, Ruby or Go and have started with Rust – what has been your experience so far regarding learning the language? I want to devote 2018 to learn a new language and I'm very interested in Rust - before I dive in it would be nice to get some impressions. Thanks for any feedback!
Steve Klabnik
@steveklabnik
Jan 19 2018 13:15
i came from ruby and am now on the core team
it was before 1.0 though so i didn't really learn today's rust directly :)
cryptopatrick
@cryptopatrick
Jan 19 2018 13:16
Wow! I was reading some of your blog posts this morning! Really liked the one about spending an entire weekend reading 800 issues. You're one smart guy, Mr. Klabnik!
What I like about Rust (without knowing much about it) is that it feels like it's still early days - that people can really make a difference and help the project. But I must admit I'm a bit afraid that the language will be way to complicated for me. And I don't like semicolons - but I guess that's just something to get used to. :)
Steve Klabnik
@steveklabnik
Jan 19 2018 13:19
thanks :)
yeah, you get used to it
Michal 'vorner' Vaner
@vorner
Jan 19 2018 14:48
@cryptopatrick I came from the world of Perl, Haskell and C++ (also some Lua), so I can't relate directly. But I've spend some time teaching programming. Not Rust, specifically, but anyway. I think you can expect Rust to be more complex then these languages, and much more stricter teacher ‒ the compiler will be more picky about your code. Rust is a bit rough teacher too ‒ it presents with the full problem. It does help you solve the problem, by checking you don't do something incredibly stupid, but you still have to do all the work yourself. This means you learn much more (which is both good and bad). But you shouldn't be afraid of the complexity ‒ it's not that bad, it just takes some work to get used to and get through it, if you have enough motivation.
cryptopatrick
@cryptopatrick
Jan 19 2018 15:27
@vorner Thank you for your answer! It's funny being afraid of a language - I guess I haven't really recovered from my experience with having to code in Prolog . Anyway, I'll try to seek out some Go devs who also code in Rust and ask for their feedback. Thanks!
Michal 'vorner' Vaner
@vorner
Jan 19 2018 15:29
Prolog is different. It thinks different. Rust still has all the ifs and whiles and so on. It just lets you tweak with much more details and lets you specify much more details.
Patrick Elsen
@xfbs
Jan 19 2018 15:32
Quick question: is there a way to make an infinite list in rust, to use for lazy comprehension, like this:
(0..inf).find(|n| *n == 9)
// => Some(9)
Steve Klabnik
@steveklabnik
Jan 19 2018 15:33
leave off the inf
and that works. well, it creates an iterator
err wait, you said find not filter
heh
 let nine = (0..).find(|&x| x == 9);
yup
(i slightly prefer the & version but the * works too
)
Patrick Elsen
@xfbs
Jan 19 2018 15:39
Omg that's amazing! Thanks a lot :)
Steve Klabnik
@steveklabnik
Jan 19 2018 15:39
np :)
Ryan
@rnleach
Jan 19 2018 15:45
I ran rustup component add rustfmt-preview and it installed rustfmt, now how do I run it on a project. When I run cargo fmt, it says that the binary cargo-fmt is not installed. This keeps changing! I'm on OSX right now.
Steve Klabnik
@steveklabnik
Jan 19 2018 15:45
  1. what toolchain are you on
Ryan
@rnleach
Jan 19 2018 15:45
stable, it wouldn't install for nightly
Michal 'vorner' Vaner
@vorner
Jan 19 2018 15:45
Every time I see this, I'm a bit sad Rust didn't get more syntax from haskell. It has great ways to write lambdas, like .find((== &9)) would be good.
Steve Klabnik
@steveklabnik
Jan 19 2018 15:46
it's not on stable yet
Michal 'vorner' Vaner
@vorner
Jan 19 2018 15:46
@rnleach There was some bug somewhere which can be fixed by rustup self update. I think.
Steve Klabnik
@steveklabnik
Jan 19 2018 15:46
or rather
whats on stable is only rustfmt, not cargo fmt
it will be in the next release
itll be back in tomorrow's nightly, probably, as well
Ryan
@rnleach
Jan 19 2018 15:47
What about nightly? ....Ok
Steve Klabnik
@steveklabnik
Jan 19 2018 15:47
components are not guarnteed to always be in every nightly
Patrick Elsen
@xfbs
Jan 19 2018 16:16
Why not run rustfmt with rustup run nightly cargo fmt ? That's how I run it anyways
Patrick Elsen
@xfbs
Jan 19 2018 17:29
Is there anything in rust to turn an u32 into an Iterator over it's digits in a given base?
red75prime
@red75prime
Jan 19 2018 17:30
.to_string().chars()
red75prime
@red75prime
Jan 19 2018 17:35
while n > 0 { let digit = n % base; n /= base; }
Patrick Elsen
@xfbs
Jan 19 2018 18:07
Got it :)
And I have yet another dumb question: how can I change this code such that the borrow lasts long enough: https://gist.github.com/8d184bf4e99326fb52e0591ebb231396 ?
Steve Klabnik
@steveklabnik
Jan 19 2018 18:27
a is only valid in the closure for flat_map
oh wait
i mis-read the nesting
make the inner closure a move one
it's just a number so that's the most straightforward
Jacob Flores
@flores-jacob
Jan 19 2018 19:31
@vorner Thanks for that vid. It did cover pretty much all of the questions I have regarding contributing so far.
Jacob Flores
@flores-jacob
Jan 19 2018 19:45
@cryptopatrick I do python (and some C++), and I've also just started learning Rust this past week or so. I'm going through the Rust Book (2nd ed) , and I think it's organized and written pretty well. I've only finished up to chapter 4 myself, but the first few chapters do provide enough guidance so that you're pretty much prepared to write basic rust code. I haven't gone through the rest of the chapters yet, but i think they deal more with things that are specific to rust. Most of the basics though have been covered quite well by chapters 1 to 3, which you can go through in less than a day.
Michal 'vorner' Vaner
@vorner
Jan 19 2018 20:14
@cryptopatrick Oh, the book is available online, you don't have to buy it if you don't have to.
cryptopatrick
@cryptopatrick
Jan 19 2018 20:56
@vorner Oh, great! I look for it tomorrow. Thanks for the tip!