These are chat archives for rust-lang/rust

27th
Sep 2017
Fra ns
@snarf95_twitter
Sep 27 2017 05:53
Can recommend https://rocket.rs/
TatriX
@TatriX
Sep 27 2017 06:19
The most popular one is iron as I can. Any reasons why I should skip it?
TatriX
@TatriX
Sep 27 2017 07:01
Rocket depends on nightly. Is it a good idea to use it instead of stable?
lemonxah
@lemonxah
Sep 27 2017 07:02
i am using rocket.rs as well
but i don't know how long it will take for roket.rs to be able to compile on stable
i am hoping its happening in months rather than years
Jonas Platte
@jplatte
Sep 27 2017 07:49
@TatriX It's not a huge deal IMHO
Oh, and I'm actually watching a talk by the author right now and he just talked about stability :D https://youtu.be/t_FUZ34ahBE?t=29m33s
lemonxah
@lemonxah
Sep 27 2017 08:10
is there a way to have private repos that is not git repo based?
like a private crate.io server?
Michal 'vorner' Vaner
@vorner
Sep 27 2017 08:11
@lemonxah AFAIK not yet.
lemonxah
@lemonxah
Sep 27 2017 08:11
so how do you guys do private crates? i have some code that is to be shared between 50 apps
but i dont really want to put it on crates.io and stupid mac has this ssh-agent issue where i cant download the crate using ssh
Aleksey Kladov
@matklad
Sep 27 2017 08:12
@lemonxah it's almost there :) rust-lang/rfcs#2141
The implementation is here: rust-lang/cargo#4506
lemonxah
@lemonxah
Sep 27 2017 08:14
awesome
if you had to venture a guess on timelines would it be in days, weeks, months?
Aleksey Kladov
@matklad
Sep 27 2017 08:16
I'd say the implemenation will be merged in days/weeks, and it'll be available on nightly.
lemonxah
@lemonxah
Sep 27 2017 08:16
i am using nightly already with rocket.rs so that would be cool
Aleksey Kladov
@matklad
Sep 27 2017 08:18

Well, you could try the PR out right now :) It's really easy (though hackish) to install cargo from sources (provided that you have CMake and openssl):

cargo install --git https://github.com/withoutboats/cargo --branch alt-registries --force

Keep in mind that force will override your current Cargo installation though.

lemonxah
@lemonxah
Sep 27 2017 08:43
could you undo that install?
Aleksey Kladov
@matklad
Sep 27 2017 08:44
if you are using rustup, then cp ~/.cargo/bin/rustc ~/.cargo/bin/cargo will do the trick.
under rustup, rustc and cargo are identical binaries, distinguished by argv[0].
lemonxah
@lemonxah
Sep 27 2017 08:44
ok cool
thank you i will try it out, although how do you create the alt-registry?
what kind of registry is it?
Aleksey Kladov
@matklad
Sep 27 2017 08:46

Hm, I think the idea is that you use crates.io codebase literaly: https://github.com/rust-lang/crates.io.

@carols10cents should know more!

lemonxah
@lemonxah
Sep 27 2017 08:51
does the alt-registries also use default registry for items not found in the alt-registry? or should i setup my registy as a clone
Aleksey Kladov
@matklad
Sep 27 2017 08:52
Yep, it uses crates.io by default, and you need to specify the registry explicitly for company-specific dependencies .
lemonxah
@lemonxah
Sep 27 2017 08:53
cool :) thank you a lot, will be testing this out
Aleksey Kladov
@matklad
Sep 27 2017 08:53
It's also possible to set-up a local mirror of crates.io to avoid reading into the wide internet, but that's an orthogonal feature
@lemonxah please add your experience to the PR with implementation or RFC, this would be useful :)
lemonxah
@lemonxah
Sep 27 2017 09:06
@matklad will do
lemonxah
@lemonxah
Sep 27 2017 09:24
is there any documentation on how to run crates.io?
Aleksey Kladov
@matklad
Sep 27 2017 09:25
I am afraid no, and I don't know this either. Perhaps something is written somewhere in the RFC though? I'll ask at Cargo IRC channel
lemonxah
@lemonxah
Sep 27 2017 09:26
i got it running kind of but have some errors :) i will go to that channel too
lemonxah
@lemonxah
Sep 27 2017 13:27
when compiling my app i get
error: `std::sync::atomic::AtomicBool::new` is not yet stable as a const fn
   --> /Users/rynokotze/.cargo/registry/src/github.com-1ecc6299db9ec823/yansi-0.3.3/src/lib.rs:479:57
    |
479 | #[cfg(feature="nightly")] static DISABLED: AtomicBool = AtomicBool::new(false);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: in Nightly builds, add `#![feature(const_atomic_bool_new)]` to the crate attributes to enable

error: aborting due to previous error

error: Could not compile `yansi`.
and i am unsure how to add that #![feature(const_atomic_bool_new)] to the create attributes
Zakarum
@omni-viral
Sep 27 2017 13:29
Make #![feature(const_atomic_bool_new)] apear as one of the first lines in your lib.rs or bin.rs
lemonxah
@lemonxah
Sep 27 2017 13:29
is that my crate's attributes? i am not using yansi its part of another library
@omni-viral that has made no difference
Zakarum
@omni-viral
Sep 27 2017 13:30
Ofc
You need to add #![feature(const_atomic_bool_new)] to the yansi :smile:
lemonxah
@lemonxah
Sep 27 2017 13:31
yeah and i dont have yansi since its a depency of one of my dependencies
Zakarum
@omni-viral
Sep 27 2017 13:31
do you use nightly?
lemonxah
@lemonxah
Sep 27 2017 13:31
should i just rollback my nightly then i think
yeah i am on nightly cause of rocket.rs
Zakarum
@omni-viral
Sep 27 2017 13:31
I think you should ask yansi maintainers to fix this
Until then you have to rollback to whatever version was working for you
lemonxah
@lemonxah
Sep 27 2017 13:33
maybe i shouldn't be using nightly then
meh
Zakarum
@omni-viral
Sep 27 2017 13:35
I see yansi enable #![feature(const_atomic_bool_new)] if nightly feature is specified
It is what I see in master
lemonxah
@lemonxah
Sep 27 2017 13:35
oh cool, i am sorry to ask this but i am new :) how do i specify features
i guess this is in the Cargo.toml?
oh but i cant since i am not using yansi its a dependency of a dependency
Zakarum
@omni-viral
Sep 27 2017 13:36
Yes. But you only specify features for your deoendencies. And yansi isn't
lemonxah
@lemonxah
Sep 27 2017 13:36
can i just include yansi myself and then the depency would use that version?
Zakarum
@omni-viral
Sep 27 2017 13:36
From error string I see that nightly feature is already enabled
Maybe it was fixed in master
There is 0.3.4 version in crates
Try to run cargo update
Because you try to compile 0.3.3
lemonxah
@lemonxah
Sep 27 2017 13:38
of rocket.rs yeah
Zakarum
@omni-viral
Sep 27 2017 13:38
yansi-0.3.3
lemonxah
@lemonxah
Sep 27 2017 13:38
oh ok .. i dont know :)
well after updating i see that that was infact the case it did have yansi 0.3.3
Zakarum
@omni-viral
Sep 27 2017 13:39
Try to run cargo update and build again
lemonxah
@lemonxah
Sep 27 2017 13:40
thank you it did in fact work for me
Zakarum
@omni-viral
Sep 27 2017 13:40
You're welcome
lemonxah
@lemonxah
Sep 27 2017 13:40
just a question regarding that
i am not explicitly including yansi in my project and i dont know which of my depencies is actually using it, is there a dependency tree tool in cargo?
Aravindh Sridharan
@hardvain
Sep 27 2017 18:07
Can someone tell me why the code snippet below fails to compile:
fn failed_borrow<'a, 'b>(y: &'a i32) {
    let _x: &'b i32 = y;
}
The error is
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
 --> src/main.rs:5:23
  |
5 |     let _x: &'b i32 = y;
  |                       ^
  |
note: ...the reference is valid for the lifetime 'b as defined on the function body at 4:1...
 --> src/main.rs:4:1
  |
4 | / fn failed_borrow<'a, 'b>(y: &'a i32) {
5 | |     let _x: &'b i32 = y;
6 | | }
  | |_^
note: ...but the borrowed content is only valid for the lifetime 'a as defined on the function body at 4:1
 --> src/main.rs:4:1
  |
4 | / fn failed_borrow<'a, 'b>(y: &'a i32) {
5 | |     let _x: &'b i32 = y;
6 | | }
  | |_^
But isnt the lifetime of ‘a is higher than ‘b because ‘a is coming from the call site and ‘b is local to the function?
elias
@ejmg
Sep 27 2017 18:24
Anyone else going to Strange Loop? About to head-off in 2 hours after my last class for the day.
Steve Klabnik
@steveklabnik
Sep 27 2017 18:41
@hardvain "let _x: &'b i32 = y;" isn't even really valid syntax, you can only use 'b in the parameter list
that said
this does compile
which is what the error is about; this informs rust that 'a lives longer than 'b
i am pretty weirded out that this compiles though
Aravindh Sridharan
@hardvain
Sep 27 2017 19:50
@steveklabnik As ‘a lives longer than ‘b, isnt it fine to assign it to a variable with lifetime ‘b? Because ‘a will still be valid when ‘b goes out of scope. isnt it?
Steve Klabnik
@steveklabnik
Sep 27 2017 19:52
you generally cannot "assign lifetimes" to things
they're used in type signatures to connect the lifetime of various arguments
Aravindh Sridharan
@hardvain
Sep 27 2017 19:55
Do you mean that I cannot annotate the lifetime of _xas ‘b in the above code?
Steve Klabnik
@steveklabnik
Sep 27 2017 19:55
yes, i am pretty shocked that that compiles
@nikomatsakis ^ ?
Niko Matsakis
@nikomatsakis
Sep 27 2017 19:57
@steveklabnik what is the question exactly?
Steve Klabnik
@steveklabnik
Sep 27 2017 19:58
check the paste above
Niko Matsakis
@nikomatsakis
Sep 27 2017 19:58
why does this compile ?
Steve Klabnik
@steveklabnik
Sep 27 2017 19:58
you can say "let x = &'b " and it works?
Niko Matsakis
@nikomatsakis
Sep 27 2017 19:58
why is that weird?
you are saying it in a type
we don't (yet?) support it in the expression
i.e., you wrote let x: &'b u32 = ...
not let x = &'b ...
Steve Klabnik
@steveklabnik
Sep 27 2017 20:00
...wow
this is.... like blowing my mind
fn foo<T>() { let x: T; } works too
nikomatsakis @nikomatsakis surprised that this surprises you :)
Niko Matsakis
@nikomatsakis
Sep 27 2017 20:01
so yeah you can use named lifetimes in types
in that case, it's legal because 'a outlives 'b
Steve Klabnik
@steveklabnik
Sep 27 2017 20:02
i mean, of course it's part of the type
but i only thought <> was "in scope" for the signature
not the body
mnivoliez
@mnivoliez
Sep 27 2017 21:12
hello
I got a question. I'm trying to filter a vec of struct. each struct has himself a vec of "behaviors". I try to filter the vec of struct to obtain a vec containing only struct with the biavior A
here is the code:
let lights = gos.iter()
        .filter(|go| go.behaviors.contains(Behavior::LIGHT_EMITTER))
        .collect();