New post: Rust by trial and error #9

Merged
merged 2 commits into from Oct 17, 2015

Conversation

Projects
None yet
3 participants
@IanWhitney
Owner

IanWhitney commented Oct 2, 2015

No description provided.

+
+In Ruby a instance method automatically has access to `self`. [Rust methods don't](https://doc.rust-lang.org/stable/book/method-syntax.html). I'm fuzzy on this point, but here's what I think is going on. In the Ruby code `year.is_leap?`, `year` is the receiver of the `is_leap?` method call. Inside the method the receiver can be accessed by using `self` (or leaving `self` off entirely, in most cases).
+
+But because of Rust's focus on proper memory management, we have to tell the method how it's going to use the receiver so that it can properly handl the memory. Is it a reference, a value or a mutable reference. I'll be honest. I don't quite understand what that means. And I might be totally wrong about all of it! But `&self` is the most common way of providing self, so that's what I'm doing.

This comment has been minimized.

IanWhitney added a commit that referenced this pull request Oct 17, 2015

Merge pull request #9 from IanWhitney/rust
New post: Rust by trial and error

@IanWhitney IanWhitney merged commit af8f0a1 into master Oct 17, 2015

@IanWhitney IanWhitney deleted the rust branch Oct 17, 2015

@amaceing

This comment has been minimized.

Show comment
Hide comment
@amaceing

amaceing Apr 5, 2016

Hey man, I just read your Rust by its Core Values blog and really liked it. Taking a look at your other Rust articles and just finished this one as well. I've learned more about Rust in those two articles than the 3 times I've tried to read the documentation/book.Keep them coming!

With your Rust experience now, was the implementation of this test case a little overkill? Feels very Ruby.

amaceing commented Apr 5, 2016

Hey man, I just read your Rust by its Core Values blog and really liked it. Taking a look at your other Rust articles and just finished this one as well. I've learned more about Rust in those two articles than the 3 times I've tried to read the documentation/book.Keep them coming!

With your Rust experience now, was the implementation of this test case a little overkill? Feels very Ruby.

@IanWhitney

This comment has been minimized.

Show comment
Hide comment
@IanWhitney

IanWhitney Apr 5, 2016

Owner

@amaceing Glad you liked them. My Rust code is definitely going to look Ruby-ish. For the purposes of passing the tests, this code is overkill. But as part of a 'real' code base, maybe not.

Owner

IanWhitney commented Apr 5, 2016

@amaceing Glad you liked them. My Rust code is definitely going to look Ruby-ish. For the purposes of passing the tests, this code is overkill. But as part of a 'real' code base, maybe not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment