These are chat archives for rust-lang/rust

14th
Jul 2018
Michal 'vorner' Vaner
@vorner
Jul 14 2018 18:24
Hello. If I do cargo test -- --ignored, it runs the ignored tests, but not the ordinary ones. Is there a way to run both the ignored and „normal“ ones?
Zachary Neely
@zrneely
Jul 14 2018 19:11
Is specialization usable on nightly?
Judson Lester
@nyarly
Jul 14 2018 20:07
I feel like I keep running into this: I've got a (tokio related) situation where I "can't move out of borrowed content", but making the value a reference is a problem because I need a static lifetime.
I could see about implementing clone, but it'd mean putting restrictions on the type I'm using.
There isn't a reasonable way to get a static lifetime for a reference to a value in a function, right?
Denis Lisov
@tanriol
Jul 14 2018 20:14
@nyarly This is a common problem with async, yes. And yes, you need to clone, possibly an Arc
Judson Lester
@nyarly
Jul 14 2018 20:14
Thanks.
I have this ongoing feeling that I'm developing habits and superstitions around how to address (for example and especially) the borrow checker, and I live in ongoing anxiety that they're bad habits.
Like, obviously I don't want to just clone everything...
But that's a lot easier than spending a lot of deep reflection on every objectionable memory access.
Denis Lisov
@tanriol
Jul 14 2018 20:21
Futures shall become more happy with references with async, but for now cloning is the way out.
Judson Lester
@nyarly
Jul 14 2018 20:27
And if the type I'm using isn't itself clone, Arc::new(v).clone() seems reasonable?
Denis Lisov
@tanriol
Jul 14 2018 20:29
Depends on what's that and what you want to do... sometimes you may need even an Arc<Mutex<T>>
Judson Lester
@nyarly
Jul 14 2018 20:33
Okay... Checking my understanding - in this case, I'd create the Arc, and it gets moved into a closure, so it doesn't get dropped and fulfills the Runtime::spawn static lifetime requirement.
This is in a test support struct, and I'm thinking about if the server should be reused, or if each test should have its own server.
I should look at how it's used, I suppose. Possibly two types are called for.
As a consumer, I can see how I'd want the former guarantee, but sometimes need the latter freedom.