Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overview of type conversion traits and techniques in Rust (beginner) #15

Open
caspark opened this issue Aug 14, 2016 · 0 comments
Open
Labels

Comments

@caspark
Copy link
Contributor

caspark commented Aug 14, 2016

One of the things that new Rust developers struggle with is how to handle conversions between types. For example, "I have a str, how do I get a String?" has several answers (and it's not necessarily the same patterns as going from a String to a str - e.g. .to_string() is str-to-String specific), and it gets trickier if you want to return "str or String" (have to use Cow, plus there's also the Borrow and BorrowMut traits which have subtly different use cases to the AsRef and AsMut traits.

It'd be great if someone could give an overview of this in a newbie friendly way; all the information is available in decent format for consumption so it should just be a matter of learning it yourself and then presenting on it.

On a related note, at least one of the conversion traits (From) are also used for error handling with the try! macro (and I believe the upcoming ? syntax on Result too) to cut down on boilerplate, so it's probably worth touching on that too? (and/or error handling techniques could be a separate talk too.)

Useful sources for people putting talks together:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant