« first day (1400 days earlier)      last day (2106 days later) » 

Tim
8:14 AM
stackoverflow.com/a/51790493/3131852 is not available in nightly 2018-08-13 -- right? At least here it's not working.
 
 
2 hours later…
10:33 AM
I want to test an implementation that uses a native function std::fs::metadata and preferably I want to use dependency injection. But I can't seem to figure out how to do it. I've defined the struct for the implementation with a generic that in my head would be the fs module. But it seems like Rust doesn't accept modules to be passed into the implementation like that? I get expected trait, found module fs`.
Hope all of that makes sense, I'm in a bit of a rush. It feels like I'm missing something very obvious but I can't seem to figure out what. Any help is appreciated.
 
11:04 AM
Never mind, I think I got it. Using Traits is the way to go. Some Rust's features are hard to process for me, it seems.
 
11:16 AM
@simeg It was our pleasure to be your rubber duck. :)
 
@E_net4 :D you know people always joke around about rubber ducking, but from my experience it's one of the best debugging "tools" there is
Note to self: buy rubber duck
 
11:38 AM
@simeg Some of us can do Ferris plushying. ;)
 
12:37 PM
@Tim I just commented, since I can't get it working either. @Shepmaster might have made a mistake or we two are stupid :3 (and yes, that nightly has the change -- unknown features lead to an error)
The PR introducing default-run is lacking explanation again. This is honestly one of the most annoying things in the Rust community to me. These PRs of regular contributors without any explanations of what changed. This one at least had a reference to the issue, but that's not really helping either.
Oh nevermind, maybe the change is not in the nightly yet °_° I think the feature actually existed before. Sorry! So we might need to wait for tomorrow nightly.
 
That moment when another programming language community makes their package manager in Rust. <3
 
Tim
It's not in the nightly, the tests for this features are implemented, so either it's working or it's not shipped ;)
 
@E_net4 NPM?
 
Tim
However, I find it weird, that the default-run is not specified in the virtual manifest
 
@Tim Yip, thought so as well.
 
Tim
12:49 PM
But if you think a step further: You don't specify the default run on the virtual manifest but for a sub crate. And iff you only have one binary, this will be executed
If you have multiple binarys in one crate, the defaulted will be used
If I got this correctly...
 
I will simply try again tomorrow ^_^
 
Tim
Same :)
If we have another nightly tomorrow ;P
 
Yeah, let's just hope nightlies make another week-long break :P
Oha, Shep edited the answer :o
 
@Tim @LukasKalbertodt i wouldn't say stupid, but yep you are both wrong ;-)
 
Tim
sigh
 
12:53 PM
I figured that having the extra binaries did make it more confusing
so I removed them and moved that to the end
 
@Shepmaster But ... so it isn't in the current nightly, correct?
So we lazy people who don't wanna compile cargo themselves have to wait, right? :P
 
@LukasKalbertodt yep
cargo is a submodule of the Rust repo
so someone has to submit a PR that updates the version of cargo in rust-lang/rust
IIRC / last I checked
 
Tim
I just found my dead lock: I called warn!() inside of Display...
 
@Shepmaster Ah, I understand. °_°
 
Tim
Are we Inception yet? You can't print while you're printing...
 
1:00 PM
@Tim Well, Display is not only printing. And indeed, you shouldn't print in it, I'd say :/ All "output" should be written into the fmt::Formatter
 
Tim
I know, just copy-pasted the code...
 
@LukasKalbertodt That ain't new. I meant this thingy.
 
@E_net4 Ah, interesting
 
Note that the CLI application is written in Rust, unlike with npm.
 
@E_net4 many Idris people seem to be confused why it's written in Rust...
 
1:09 PM
(Also note npm is usually spelled in lower case)
 
@E_net4 N_P_M
alias CARGO=cargo
 
Yelling is unwelcome and unfriendly. :(
 
@E_net4 True :/
 
Let us be careful. Our comments can be flagged for their unfriendliness alone now.
 
Guys, how can I sort items in a collection after calling iter().filter() ?
collection.iter().filter(|i| i % 2) - is not ordered from time to time
I need it to be in the same order as it was
in the original collection
I tried to find something like sort() in iter but I did not find it
 
1:21 PM
Hi @VictorPolevoy! What collection are you using? A simple Vec<T>?
 
Nope, multimap.
Or, probably, the problem could be in for_each, I call it right after the filter()
for printing elements
and it always print items in different order
 
    self.data
        .iter_all_mut()
        .filter(|(price, _items)| price < &&input_price)
        .for_each(|(parent_price, items)| {
yes, this
I did not even expect this behavior
this is so strange
 
So that crate is "a thin wrapper around std::collections::HashMap". And that hashmap does not have a deterministic ordering. It's a security measure, but the order of elements in the hash map is basically random.
The problem has nothing to do with your filter or for_each. It's simply that a HashMap (and thereby a multimap) doesn't keep the elements in a deterministic order.
 
@LukasKalbertodt That question seems dangerously broad, doesn't it?
 
1:27 PM
@E_net4 Mhh I don't know, I think it's fine? Dunnoo
 
@LukasKalbertodt It has attracted answers like "use X crate" and "use Y crate".
 
Okay, I mapped everything into a Vec after filter
And so I can order
 
@VictorPolevoy Yeah, that's a solution :)
@E_net4 Mh truue :/
 
thank you guys
I missed that point of hashmap somewhy
probably just wanted to do everything so quickly without thinking :)
 
@LukasKalbertodt I'd be pedantic and say that the order of a HashMap is deliberately undefined
And then the fact that two hashmaps in the the same process having different (but still undefined) orders is a security consideration
 
1:37 PM
@VictorPolevoy Who doesn't know that situation ^_^
@Shepmaster yip, I agree
 
@LukasKalbertodt Amusingly, more and more frequently, I've been reading an answer and thought "why didn't I upvote this" to find out it's my answer.
2
 
@Shepmaster That already happens to me, I can somewhat imagine how often it happens to you :D
 
1:54 PM
:)
 
"Why can't I upvote- oh."
 
2:18 PM
It's more confusing when you sometimes use the mobile app, because the answerer and editor are reversed.
 
 
1 hour later…
3:41 PM
In the example, you can simply add a #[derive(Copy)] to give Vec3 copy semantics. — trentcl 5 mins ago
^ The OP suggested I should make this an answer.
It doesn't really seem to fit either of the other linked questions IMO
And yet it seems like this should be a duplicate of some question somewhere.
Any opinions?
 
> How do I implement the Add trait for a reference to a struct? doesn't help as it requires specifying lifetimes for object which I'm not at yet.
I don't know that "I'm not there yet" is a valid thing
 
@Shepmaster True. But the questions are still different, and this one doesn't necessarily call for references
 
@trentcl I mean, they asked for "without moving"
If you implement Copy, then the value is still moved
/pedant
 
@Shepmaster "without moving out of" ?
is there a better place than on this question, to put the answer "just derive Copy"
 
@trentcl Hmm
I'm searching for some potential duplicate
@trentcl Why do you think it wouldn't fit on the first linked one though?
 
3:53 PM
@Shepmaster I considered that one, but it does specifically ask about references
 
Or impl Sub for &'a Vec3 instead?
 
Recently I was lightly criticized for reading too much into someone's question, so maybe I'm being overly cautious ^_^
 
@trentcl But yeah, if you reword it to this style, then I suppose you can say Copy (and might as well throw in Clone as well) and please link to whichever other Q is most useful
And maybe point out
> which does not implement the Copy trait
that the compiler told them this solution ^
@trentcl Was it me that did this criticizing?
 
@Shepmaster No.
 
@trentcl whew
 
3:58 PM
@Shepmaster also good point
 
4:33 PM
@trentcl were you gonna tweak the question as well?
 
@Shepmaster Was, but preoccupied :/
 
k
just didn't want to step on pending edits
 
@Shepmaster nothing right now
 
Tim
4:53 PM
Why does all methods from Pattern consumes self? This is pretty restricting.
 
@Tim Note that its implementors are mostly Copy or reference types
 
Tim
Ah, good point, thanks
 
5:18 PM
@Tim See also the awesome pattern3 API RFC
 
(which also consumes self :p)
 
@kennytm but it justifies it (the analogy to IntoIterator)
 
yep :)
 
 
4 hours later…
Tim
! should implement Fail :)
 
Tim
10:13 PM
Heh
 
10:24 PM
I don't like much program that use !
a good program should exit by main
exit is for weak
 
Tim
What about calling exit in main?
 
10:43 PM
@Stargateur In the future, ! will be more prevalent
Did you see the recent answer?
11
A: Why does Rust have a "Never" primitive type?

Matthieu M.TL;DR: Because it enables local reasoning, and composability. Your idea of replacing exit() -> ! by exit<T>() -> T only considers the type system and type inference. You are right that from a type inference point of view, both are equivalent. Yet, there is more to a language than the type system...

 
@Shepmaster yep but that doesn't change my mind
I don't like use it
 
@Stargateur My point is that your two statements are of different scope
number-of(programs that use !) >> number-of(programs that don't exit by main)
 
Tim
How many members of the lib team are required to approve a merge? (waiting for find_map on Iterator)
this feels soo ugly: self.locations.iter().find(|(_, location)| location.exists(resource)).map(|(key, _)| key)
 
11:00 PM
@Shepmaster yeah, I was speaking about exit case but I didn't yet see a lot of good use of ! other than exit, or exec family etc
 
The Julia benchmarks for comparison with other languages, as shown online, now includes Rust. :) julialang.org/benchmarks
 
@Tim a merge is generally 1. Stabilizing a feature that has to be supported by Rust forever? That takes a majority of the team
@E_net4 Nice work!
@E_net4 Now fix the results. Rust is sometimes slower than other languages
 
@Shepmaster I think I've seen that indeed.
 
I think that's how to beat LuaJIT
 
@Shepmaster there are known issues in the actual benchmarks which might be making too many "unreasonable" optimizations.
 
11:13 PM
@E_net4 the Rust impl or other languages?
 
@Shepmaster C, for example.
As for LuaJIT, this could be a matter of buffer size fine tuning.
Did you see how fast Lua was at print_to_file? Very odd.
 
@E_net4 what's "unreasonable"?
 
print to file should be equivalent in almost all language
 
@Shepmaster The compiler changing the code in a way which does no longer employ the intended algorithm.
For example, the Fibonacci one must be the recursive impl, with recursive calls and all that.
Clang is known to seamlessly memoize these.
@Stargateur You may wish to have a look at the code and see whether that is actually true. Maybe there's an unfair optimization or whatnot.
 
@E_net4 there moved again this repo ??
 
11:43 PM
finally refind it
 

« first day (1400 days earlier)      last day (2106 days later) »