« first day (2571 days earlier)      last day (900 days later) » 

5:55 AM
@DenysSéguret FAIL
 
 
6 hours later…
11:29 AM
Finally, some question worth answering.
 
 
3 hours later…
2:02 PM
@E_net4thecurator not dolphin's question I guess
 
Nope.
That one, someone should probably send a link to [mre].
 
I don't read them anymore so
question is rust edition allow breaking change of rust std ?
cause 2021 forget to reverse arg order of doc.rust-lang.org/std/mem/fn.replace.html
and that sad
 
@Stargateur Well, generally it cannot.
The array IntoInter impl was an exception attained through a workaround.
But other than those workarounds, std cannot be subjected to breaking changes.
 
annoying to add:
fn replace<T>(src: T, dest: &mut T) -> T {
  core::mem::replace(dest, src)
}
to my project that use replace
 
2:19 PM
I suppose you could put that in a crate with a prelude.
(If getting used to the direct use of core::mem::replace is not an option)
 
problem is not about get used, problem is borrow checker
 
:thinking:
 
replace(&mut i, i + 1);
don't compile
replace(i + 1, &mut i); compile
 
So the problem is still the order of parameters.
 
yep
 
2:23 PM
So getting used to the order of parameters is not an option?
 
well if borrow checker allow the first one I will not care
but write:
let v = i + 1;
replace(&mut i, v);
is annoying
it's like 99% of use case of replace
 
I see.
That's an intriguing one. I don't imagine the compiler managing to resolve such cases in a different way without blowing things up.
 
the more simple solution is just to swap parameters order
that a rare case but this function is quite particular
 
Yeah, I understand. Alas, there cannot be such a breaking change here.
 
maybe a solution is to add it as a new function in mem and depreciate the old replace
or just add it
named replace2
I don't have any better
 
2:32 PM
Meh, it's a lame name.
 
I try to search on github an issue about that problem but there is too many issue I didn't find anything
 
A new function would help, but some folks would not let the deprecation go unnoticed.
 
it's really an unfortunate case, I agree that depreciate it is not good either
 
2:57 PM
Yay, voting to close and answering. -_-
 
rep more need more REP
 

« first day (2571 days earlier)      last day (900 days later) »