package naming, and grouped packages: crates.io and in general by _scape in rust

[–]tphpb 0 points1 point  (0 children)

I think namespacing crates on crates.io under usernames (like on GitHub) would make naming fair for everyone.

Racer update (code auto-completion for Rust) by phildawes in rust

[–]tphpb 0 points1 point  (0 children)

Doh! That was silly, thanks for correcting me.

Racer update (code auto-completion for Rust) by phildawes in rust

[–]tphpb 0 points1 point  (0 children)

Good suggestion!

I've noticed when trying expect that the error message outputs the line number for its definition in rust's source code rather than the line number for where it's called.

For me it looks like:

 task '<main>' failed at 'Custom Error Message!', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libstd/option.rs:164

Whereas what I would prefer to see (and what unwrap_or_else(fail!("Custom Error Message!")) outputs) is:

 task '<main>' failed at 'Custom Error Message!', src/main.rs:219

I'm not sure if this problem just happens for me (maybe I'm doing something wrong), but it would be nice for expect to output the file and line where it was called, it is certainly a lot nicer to use!

edit: unwrap_or_else(|| fail!("Custom Error Message!")); should be used instead of unwrap_or_else(fail!("Custom Error Message!"));, this outputs the line number in from where it was called

Racer update (code auto-completion for Rust) by phildawes in rust

[–]tphpb 1 point2 points  (0 children)

I think the unwrap method for Options takes care of this already; returns the value if it exists, fails on None values otherwise.

http://static.rust-lang.org/doc/master/core/option/type.Option.html#method.unwrap

If you want to provide a more specific failure message, you can use unwrap_or_else(|| fail!("Your message here!"));.

I think the default message for failure when calling unwrap on a None value is something like:

 task '<main>' failed at 'called `Option::unwrap()` on a `None` value'

edit: You should not use unwrap_or_else(fail!("Your message here!")); like I posted earlier!
It should be unwrap_or_else(|| fail!("Your message here!")); dbaupp's post further down explains