« first day (2050 days earlier)      last day (1429 days later) » 

5:22 AM
> This question does not have an upvoted or accepted answer
I'm sad
 
@trentcl quite hilariously, any pathbuf seems to end with ""...
(IMO this looks like a bug but fixing it at that point would be a breaking change)
 
well as I said, path is not mean for that
you probably need a custom one
 
5:38 AM
IMO this is the point of Path. A trailing slash has a meaning in many tools, it's unfortunate it wasn't handled in the rust representation.
 
well, std is here for basic
you use case is not basic IMO
 
Basic tools like cp or mv make the difference. Do you think it's normal you couldn't use Path to describe their arguments ?
In this case, it could be fixed by just adding two public functions, we're not speaking about anything complex
 
well yes, theoretically src/main.rs/ is a file even with the extra /
 
according to what theory (rust implementation doesn't count as a theory) ? That's not how linux tools work, for example
 
and I mix up thing xd
strange example
I didn't find any crate that will fit your need
 
6:23 AM
solved. I thought the duplicated was related to docker but not so that. thank you. — v..snow 9 mins ago
and I will never get a upvote xd
 
6:38 AM
You seem to gain a lot of reputation those days, though
 
@DenysSéguret I believe both of you are correct. On one hand from semantics PoV, there's no difference between p and p/ (or in fact p// or p////). And as such the Path not acting differently in these situations seems to me as a correct behaviour. OTOH as you said, a shit load of tools treating the trailing slash semantically different (e.g. .gitignore files) which is a good thing, helps the user easily and quickly describe what they want. I believe this extra logic therefore must be
handled separately.
 
6:55 AM
@DenysSéguret I just want to close the question but I can't because both people I helped didn't upvote my answer xd
 
 
1 hour later…
8:05 AM
you said I have to consider? well, 1) I want to upvote as answer. I'm grad if you rewite as Answer. 2) I don't know how to close myself. any backdoor for asker? — v..snow 1 min ago
what ?
damm answer few questions and I'm already piss off
 
 
4 hours later…
11:52 AM
@DenysSéguret man, that's annoying. Maybe it could be fixed in some way if changing it doesn't break any crates
Since ends_with("") doesn't do anything useful it's possible there is nothing that depends on it.
 
 
2 hours later…
1:34 PM
Amusingly...
% ls -lrt /tmp
lrwxr-xr-x@ 1 root  admin  11 Oct 27  2019 /tmp -> private/tmp
% ls -lrt /tmp/
Ye olde ls also cares
Which I knew deep down
but probalby couldn't have just said so
 
of course it cares
 
well, I mean in behavior
/tmp shows the symlink
/tmp/ shows the contents of the symlink
 
oh...
 
2:20 PM
@Shepmaster That used to hit me a few years ago... then I sort of disciplined myself by stabbing a slash almost everywhere regardless of the command. :|
This is fine.
 
 
3 hours later…
5:20 PM
I've forgotten how useless sometimes comments on SO can be. Thanks for the reminder :) — Nick 6 mins ago
I've not forgotten how stupid are questions on SO can be. What you want we say ? you didn't provide ANY context. We can only repeat what miri already tell you. — Stargateur 17 secs ago
I didn't resist you can flag !
who upvote this BTW ??
user only post question... have 9k
 
5:35 PM
I'd remove the first part of your comment
He'll get flagged, no need for you to be
 
5:47 PM
@DenysSéguret done ^^
 
#[must_use]
async fn write() -> Option<()> {
    unimplemented!();
}
#[must_use] has no effect on async functions. what are my alternatives? I've started creating a MustUse<_> wrapper type, but maybe I'm overlooking a simpler option?
 
@JohnKugelman report as bug ?
 
I didn't find anything on google, which surprises me
 
must use is expected to work on function and so on async function
 
ok I'll post a question just to be sure
 
5:53 PM
note that implement this on compiler side is propably painful xd
because async generate a futures return type
if you can replace the option by result
this already have must use
also a option with must use is maybe not good
 
yeah fair, maybe I'll just switch to Result<(), ()>
 
@JohnKugelman THE OWL
@JohnKugelman You want the Option to be used? The future should be warned about by default.
 
yeah I want the option to be used
it's not an "error" if the option is None which is why I'm not already using the owl
I switched the return type so you can't just tell me to use Result :P
 
6:10 PM
cheater
 
@JohnKugelman title not a question. Asks multiple questions.
 
that ok for me
it's totally related and is a nice follow up about real solution, the first question is more or less "is it a bug btw ?"
 
Look; someone copied the same pattern seconds later
0
Q: Type inference picks the wrong supertrait

Tavian BarnesThis code: trait Foo: PartialOrd + PartialOrd<<Self as Foo>::A> { type A; } trait Bar { type B: Foo; fn bar(&self) -> Self::B; } fn baz<T: Bar>(x: T, y: T) -> bool { x.bar() < y.bar() } fails to compile with this error: error[E0308]: mismatched types --> foo.rs:12:15 ...

Anyway, I'm pretty sure that John's problem is that using a value is transitive.
at least as far as #[must_use] is concerned
 
For all the people that, unlike @Stargateur, do not consider this a stupid question, there is an open issue in GitHub for this github.com/rust-lang/rust-clippy/issues/1013Nick 10 mins ago
@Shepmaster this time I get a new friend and not you !
 
acr
6:47 PM
Hi everyone, I'm struggling with iterator API design. I have a working iterator that hands out immutable pixel references (of an image). That works fine, see: github.com/raymanfx/ffimage/blob/next/src/packed/image.rs#L144. Now I tried to introduce an iterator that hands out mutable references, but I'm getting yelled at by the compiler: github.com/raymanfx/ffimage/commit/…. See the associated CI pipeline for build errors.
My first issue is understanding why the code with the immutable references works fine, but the mutable references pose an impossible case as far as lifetimes are concerned.
I'd greatly appreciate it if someone could take a brief look at the code (it's all in that GitHub repo). I tried to create a minimal example, but there's too many traits and structs involved.
 
31
Q: How can I create my own data structure with an iterator that returns mutable references?

Mike PedersenI have created a data structure in Rust and I want to create iterators for it. Immutable iterators are easy enough. I currently have this, and it works fine: // This is a mock of the "real" EdgeIndexes class as // the one in my real program is somewhat complex, but // of identical type struct E...

 
acr
7:05 PM
Thanks, that looks like my issue. I can't quite see where I'm aliasing the same memory location twice though.
 
@acr that's irrelevant to the compiler.
You might not be.
but the compiler can't know, so it stops you
 
acr
so what exactly is it complaining about here?
 
read the entire answer
 
acr
and why is the immutable case fine?
 
because you are allowed to have multiple aliasing immutable references
hopefully you have read the book and know the rules of references
 
acr
7:08 PM
is it because my iterator tries to hand out references with lifetime 'a and they are not bound to the lifetime of the image instance?
(that's what I get from looking at that answer)
The answer is a bit confusing since it mutably borrows twice, I can see that easily. I don't see it that clearly for my code (or the code from the question) though.
Isn't the previous reference automatically invalidated when accessing the next element of the iterator?
I'm re-reading the reference section in the book to see if I missed something.
Ah, I think I'm confused in the same way as the person commenting on that answer.
"When I ask mutable iterator for next mutable reference, doesn't compiler know that the previous mutable reference is not used anymore and iterator could be unfreezed?"
Your very own answer (stackoverflow.com/questions/27118398/…) helped me understand the issue! So thank you very much.
 
acr
7:31 PM
I feel like this is missing from the book though. The comment above the mem::transmute block in your answer explains it very clearly, but there's no section in the book about this ("Iterator invalidation" does not cover it IMO).
 
8:06 PM
so apparently self is hygienic even though it's a keyword??
> self value is a keyword only available in methods with a self parameter
I'm trying to use self in an expression in a macro invocation that gets injected in a method defined by the macro
 
@FrancisGagné there are too many qualifications in this sentence, which obviously means you are doing something silly ;-)
 
@FrancisGagné I think yes
 
@Shepmaster I'm just trying to increment a counter!
 
8:22 PM
self++
 
@Stargateur ++self ;)
 
@Stargateur but I can't use self because of hygiene!
 
@PeterVaro I don't like this form !
 
8:25 PM
@Stargateur thank glob then that we don't have pre- and postfix increment operators!
 
@Shepmaster the first of these two corresponds to my case
I think I have another way of doing it in my program; I'd rather not introduce a this identifier in all invocations of this macro because most of them don't need this/self
 

« first day (2050 days earlier)      last day (1429 days later) »