These are chat archives for rust-lang/rust

11th
Jul 2018
Kelly Thomas Kline
@kellytk
Jul 11 2018 06:14
What does Cargo use to determine whether or not cargo build should trigger a full project recompile? I'm seeing behavior where, through an Ansible shell task, I copy Cargo.lock and target/ out of the code dir, wipe and recreate it, copy Cargo.lock and target/ back into the code dir, and cargo build fully recompiles
Denis Lisov
@tanriol
Jul 11 2018 09:38
At the same path?
Zakarum
@omni-viral
Jul 11 2018 10:03
@kellytk I guess cargo build checks all files involved. All files are new so it recompiles them
Kelly Thomas Kline
@kellytk
Jul 11 2018 10:31
It uses file date (https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/fingerprint.rs#L289) rather than checking if file contents have changed, unfortunately
Denis Lisov
@tanriol
Jul 11 2018 10:31
I'd guess the "file contents" part is expected to be covered by incremental compilation...
piperRyan
@piperRyan
Jul 11 2018 16:24
Was there any specific reason that FromStr for bool only matches with "true" and "false"?
Heinz N. Gies
@Licenser
Jul 11 2018 17:13
evening folks, I've some (quite a lot) trouble to wrap my head around borrowing and loops. I've looked at the docs and searched myself carzy but I can't find a solution so I come in the hope someone with more experience can share some of that :) I 'simplified' the issue I have to this http://play.rust-lang.org/?gist=4cebb243578a40ffe50349ee154b43c4&version=stable&mode=debug&edition=2015
David James
@xpe
Jul 11 2018 18:27
@Licenser I see 83 lines in your 'simplified' example :)
Carl Dong
@dongcarl
Jul 11 2018 18:33
Hi all, I'm wondering if there's a way to avoid "downstream crates may implement trait FooTrait for type Bar", my trait is private, so I'm not sure how downstream crates can implement it
David Raifaizen
@craftytrickster
Jul 11 2018 18:35
basically, you want to prevent anyone outside your crate from implementing your trait?
Carl Dong
@dongcarl
Jul 11 2018 18:36
@craftytrickster I don't mind if they do, I just want to get rid of the compiler error
David Raifaizen
@craftytrickster
Jul 11 2018 18:37
are you exposing a trait that inherits from that one?
Carl Dong
@dongcarl
Jul 11 2018 18:37
@craftytrickster I have trait FooTrait, which I'm trying to do impl<T: FooTrait> BarTrait for T on, and this is where the problem arises
BarTraitis implemented for type Bar
and I get the error "downstream crates may implement trait FooTrait for type Bar"
David Raifaizen
@craftytrickster
Jul 11 2018 18:39
is BarTrait public?
Carl Dong
@dongcarl
Jul 11 2018 18:39
Yes BarTrait is public
@craftytrickster
David Raifaizen
@craftytrickster
Jul 11 2018 18:41
@dongcarl ive never run into this error, but it seems like it would be due to the fact that your BarTrait implementation here depends on FooTrait, which is private
Carl Dong
@dongcarl
Jul 11 2018 18:41
Even if I make FooTrait public, it won't do...
dongcarl @dongcarl waits patiently for help
David James
@xpe
Jul 11 2018 18:41
@Licenser I've looked at your code -- could you come up with a simpler example?
@Licenser I'm looking more into this myself (it is not something I'm too familiar with). Have you read this: rust-lang/rust#45402 ?
David Raifaizen
@craftytrickster
Jul 11 2018 18:45
@dongcarl you are not implementing FooTrait for Bar I asume
Carl Dong
@dongcarl
Jul 11 2018 18:46
@craftytrickster No I'm not, I don't want to yet
David Raifaizen
@craftytrickster
Jul 11 2018 18:46
@dongcarl my undeducated guess is because you are creating a circular crate dependency
your lib actually depends on another lib existing to work, but that other lib depends on this one as well
Carl Dong
@dongcarl
Jul 11 2018 18:47
I'm working within my own crate no dependencies yet
"-/
:-/
David Raifaizen
@craftytrickster
Jul 11 2018 18:47
then you need to implement that trait for Bar
Carl Dong
@dongcarl
Jul 11 2018 18:48
But what if I don't want to?
David Raifaizen
@craftytrickster
Jul 11 2018 18:49
You implemented BarTrait for Bar, which implicitly says that Bar has to implement FooTrait
Carl Dong
@dongcarl
Jul 11 2018 18:50
I see what you're saying
David Raifaizen
@craftytrickster
Jul 11 2018 18:50
due to the T: FooTrait bound
David James
@xpe
Jul 11 2018 18:50
@Licenser I created four examples, all of which compile and run fine: http://play.rust-lang.org/?gist=f940378558fbef59e772b8ab5c9314ad&version=stable&mode=debug&edition=2015 -- if you can adapt one of these to show a simpler case of your problem, I think it will go a long way to figuring out a solution
Carl Dong
@dongcarl
Jul 11 2018 18:51
@craftytrickster So what if I wanted to provide a default implementation for BarTrait but ONLY for those who have implemented FooTrait
David Raifaizen
@craftytrickster
Jul 11 2018 18:52
@dongcarl curious to know myself. Does anyone know ^
Carl Dong
@dongcarl
Jul 11 2018 18:55
@craftytrickster I think the best way is through a custom Derive... But not sure how to do that
David Raifaizen
@craftytrickster
Jul 11 2018 18:56
Vyacheslav Kim (Kane)
@kanekv
Jul 11 2018 19:04
I can't recall, but I think I've seen RFC that allows to implement non-local traits for smart pointers, something like impl ExtTrait for Rc<MyType>, am I wrong?
David James
@xpe
Jul 11 2018 19:11
I'm thinking about the pros and cons of wrapper types. I would appreciate your feedback on it: https://gist.github.com/xpe/096ef03b9b2f41a48214f676cd9d05e3
Denis Lisov
@tanriol
Jul 11 2018 19:14
@Licenser IIUC, the fine point here is that your run takes as self &'pipeline mut Pipeline<'pipeline>, which is rather unusual...
Heinz N. Gies
@Licenser
Jul 11 2018 20:14
@xpe sorry for the late reply had to watch the soccer game even so Germany is out already :P I read the link but it felt different it's itering over elements of an mutable while I iterate over other elements from another source
@tanriol I think I needed that so the elements of the pipeline can motate themselfs
Heinz N. Gies
@Licenser
Jul 11 2018 20:42
@xpe re wrapped types, I have not done this in rust but I've done plenty of that in erlang and I found the advantage of having some kind of type checking huge
James Shin
@js4785
Jul 11 2018 23:45
anyone usegstreamer-rs? I've tried running an RTSP video stream with uridecodebin as an entry point, I want to get 30+ fps on (at least) a 2400x1600 res display with <500ms delay... but I've been getting <20fps with >10 sec delay, which gets even worse over time
vlc rtsp://... seems to run with exactly the speed constraints I need, but I'm hesitant to use the vlc-rs bindings because I haven't figured out how to get raw buffers from it. also, it seems pretty outdated and not well-supported