These are chat archives for rust-lang/rust

29th
Sep 2017
Horace He
@Chillee
Sep 29 2017 04:20
Could not compile rustfmt-nightly.
Does anybody know what this is caused by?
error[E0532]: expected unit struct/variant or constant, found tuple variant `RangeEnd::Included`
  --> /home/chilli/.cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.2.7/src/patterns.rs:62:17
   |
62 |                 RangeEnd::Included => rewrite_pair(
   |                 ^^^^^^^^^^--------
   |                           |
   |                           did you mean `Excluded`?
diegor8
@diegor8
Sep 29 2017 05:01
I have been meaning to convince my
Anton Ugryumov
@dvec
Sep 29 2017 05:02
Try to use previous version of rust (if you use actual) or create issue
diegor8
@diegor8
Sep 29 2017 05:03
colleagues to learn rust , has the ergonomics project already been completed / has the documentation already been updated accordignly ?
Btw ,
Zakarum
@omni-viral
Sep 29 2017 06:47
@felipesere Instead of using FnOnce(T) -> U you do add type parameter F: FnOnce(T) -> U and use F
And I afraid you can't make workable monads in rust as they require hkt
Ah. And it must by Fn not FnOnce
As you gonna call it multiple times in many implementations
mnivoliez
@mnivoliez
Sep 29 2017 07:24
Hello, How can I check if a vec of enum contains one value of enum?
Aleksey Kladov
@matklad
Sep 29 2017 07:26
vec.iter().all(|e| match e { E::X => true, _ => false})
mnivoliez
@mnivoliez
Sep 29 2017 07:41
it tells me it expects a ref
Aleksey Kladov
@matklad
Sep 29 2017 07:44

@mnivoliez yeah, you need to add the necessary about of & and *.

I think |e| match *e { E::X { .. } => true, _ => false} would type-check, but it would be useful to see a snippet of code at Rust playground (http://play.rust-lang.org/) to know for sure instead of guessing :)

the *e seems to work
Aleksey Kladov
@matklad
Sep 29 2017 07:47
Yeah, it also works as
go.behaviors.iter().all(|&b| match b {
    Behavior::LIGHT_EMITTER(..) => true,
    _ => false,
})
Note that (..): it's useful to ignore all fields if you don't need them
mnivoliez
@mnivoliez
Sep 29 2017 07:50
and (_)?
doesn't it serve this goal?
what's the differences between (..) and (_)?
Aleksey Kladov
@matklad
Sep 29 2017 07:54

_ matches a single field. To match, for example Point(f32, f32, f32), you'd use Point(_, _, _).

.. matches any number of fields, so that you can do Point(..) or Point(x, ..) if you want match only some fields and ignore the rest.

mnivoliez
@mnivoliez
Sep 29 2017 07:54
interesting
I'll keep that in mind then :)
lemonxah
@lemonxah
Sep 29 2017 10:04
is it possible to do Point(.., z)?
mnivoliez
@mnivoliez
Sep 29 2017 10:07
seem like you can
Zakarum
@omni-viral
Sep 29 2017 10:19
What is canonical way to not use Result yet not get warning?
Denis Lisov
@tanriol
Sep 29 2017 10:19
let _ = ...
Zakarum
@omni-viral
Sep 29 2017 10:19
I did the same :laughing:
Still. Thanks! @tanriol
Aleksey Kladov
@matklad
Sep 29 2017 10:22
@tanriol actually I've seen drop(...) recently as well in Cargo's code. Not sure which one is better, let _ = ... seems better to me though.
Horace He
@Chillee
Sep 29 2017 13:31
I'm still having issues setting up rls
I'm getting
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not have the binaryrls`
most of the online posts I see regarding this issue have stable instead of nightly
It has been renamed into rls-preview
Horace He
@Chillee
Sep 29 2017 13:33
thanks
the vscode extension should probably be updated
stevensonmt
@stevensonmt
Sep 29 2017 13:33

Can anyone tell me why I'm having trouble getting Rocket to parse RawStr?

#![feature(plugin)]
#![plugin(rocket_codegen)]

extern crate rocket;
use rocket::http::RawStr;

#[get("/user/<id>")]
fn user(id: usize) -> String { format!("First rank") }

#[get("/user/<id>", rank = 2)]
fn user_int(id: isize) -> String { format!("second rank") }

#[get("/user/<id>", rank = 3)]
fn user_str(id: &RawStr) -> String { format!("last rank") }

fn main() {
    rocket::ignite().mount("/", routes![user]).launch();

}

So http://localhost:8000/user/3 works, but http://localhost:8000/user/-3 or http://localhost:8000/user/three gives the error

GET /user/three text/html:
    => Matched: GET /user/<id>
    => Failed to parse 'id': RawStr("three")
    => Outcome: Forward
    => Error: No matching routes for GET /user/three text/html.
    => Warning: Responding with 404 Not Found catcher.
    => Response succeeded.
Andrey Lesnikov
@ozkriff
Sep 29 2017 13:34
@Chillee rust-lang-nursery/rls-vscode#162
Horace He
@Chillee
Sep 29 2017 13:34
@ozkriff So does that mean that rls is on stable now or something?
The RLS is now available in beta. Install it with rustup component add rls-preview. It should hit stable with version 1.21. The rls component is being renamed to rls-preview on nightly too.
Horace He
@Chillee
Sep 29 2017 13:35
:+1:
stevensonmt
@stevensonmt
Sep 29 2017 13:58
n/m my question above. figured out I needed to add the routes in the main function.