« first day (2178 days earlier)      last day (1304 days later) » 

12:01 AM
Hey anyone know how to apply a attribute to one entire module?
I want to #[allow(dead_code)] to just one entire module, is this possible?
 
#[allow(dead_code)]
mod thing { ... }
@Jesse_mw You tried this? ^
Or #![allow(dead_code)] inside thing.rs, they should do the same
 
I'll try it
@trentcl Thanks, I thought #! would apply to the entire crate.
 
12:18 AM
@Jesse_mw #! attributes just apply to the immediately enclosing module. If that happens to be the crate root (main.rs or lib.rs) then "the immediately enclosing module" would be the whole crate. But you can put them in any module.
 
1:10 AM
@trentcl move || async move {...} — closure that moves in. When executed it creates an async block that also moves things in.
 
@Shepmaster right, but passing it to thread::spawn?
 
@trentcl oh, indeed
and I think it could just be || async move {}, cause... moves
 
@Shepmaster I am admittedly a novice at async stuff, so I appreciate you confirming my suspicion here :-)
 
@trentcl heh.
(1) we are all novices at async until we die, I think
3
(2) This code works, but yeah, nonsense.
use std::thread;

fn main() {
    thread::spawn(move || async move {});
}
this will spawn a thread, when the thread starts, the closure will generate a future
the future is never executed.
and the spawned thread is racing with the main thread
 
My understanding is that some other languages have the executor built in, so async both creates and starts running the task. Maybe that's the source of the confusion
 
1:17 AM
That's very likely (I think that Go, JS fit that criteria)
Their problem at the core is interesting, as are all non-trivial things.
It's "how do I integrate blocking code and async code"
And they are generally on the right track with spawning a thread
but you have to have some magic bits between the two
I think this type of problem is why Tokio states: "Contrary to popular belief, it is ok and often preferred to use the ordinary Mutex from the standard library in asynchronous code. "
So in this case, I'd go with an Arc<RwLock<Arc<HashMap>>> (all stdlib / blocking)
then you do .read().clone() whenever you need to use it, and .write() = whatever when you want to update the value.
Then each Tokio task (or whatever) has an Arc<HashMap> without any locking.
 
1:35 AM
That makes about 60% sense to me right now... I'll try it again tomorrow morning
 
1:46 AM
🛌
 
2:08 AM
[cv-plz] stackoverflow.com/questions/64129506/… — OP states clearly they don't wish to create a MRE
 
2:25 AM
Me: Make these changes to improve your question and hopefully the chances of getting an answer
them:
 
 
2 hours later…
4:15 AM
Anyone experienced with the serenity (discord) library?
 
 
3 hours later…
6:53 AM
I've updated the version of the dependencies of a program. About a dozen crates I used had a new version. NONE OF THEM had a changelog. Even popular crates like rayon or git2 don't have changelogs. WTF people.
 
7:26 AM
(rayon has one)
 
8:10 AM
@DenysSéguret This occasionally trips me too. And sometimes it's just because I failed to find it.
But projects completely devoid of changelogs are not unheard of.
 
People go at lengths making a very detailed documentation, answer issues, publish to crates.io, make new releases... and fail at the one tool helping crate users upgrade
There should probably be "changelog" entry in Cargo.toml and a "changelog" tab in crates.io
 
@DenysSéguret It's an interesting idea, although I image either that adapting to projects using GitHub releases, or forcing the opinion of using a committed file.
 
8:25 AM
IMO we shouldn't stick to GitHub too much
 
@DenysSéguret Not all crates / projects need that. If your application has a single version at any given time (e.g. a server / service) which is using CD then you don't need a CHANGELOG
@DenysSéguret +100
 
 
3 hours later…
11:34 AM
@E_net4changesdisplayname You can make it a URL instead.
@DenysSéguret I have a semi-copy-pasta issue for that. A recent usage
 
11:46 AM
I often mention keepachangelog.com
 
12:44 PM
I don't keep a changelog for my "silly" projects. I should start creating a file that says "If you use this project and are reading this changelog, file an issue so I know to start keeping one"
Also, some people don't tag their repos with versions
oh man is that annoying
 
 
1 hour later…
2:11 PM
Damn.
Found the dupe after the answer was accepted.
I love flagging my own answers.
 
 
1 hour later…
3:36 PM
Blame the system. It should have been easier to find the dupe than to write an answer. ;)
 
@E_net4changesdisplayname sadly, the titles are pretty similar (course I edited both)
 
Then why didn't the system immediately raise an alarm before the question was asked? :)
 
> I edited
so the original title wasn't that close
 
Heck, YouTube Music is horrible.
 
but then I moved stuff from the body into the title
 
3:59 PM
            self.display_img = Some(CachedImage {
                target_width,
                target_height,
                img,
            });
            &self.display_img.as_ref().unwrap().img
Is there a clean way to avoid this ugly unwrap ?
 
4:16 PM
If you unwrap my answer to that question, I'll panic.
 
got it
With all its functions, Option still lacks some ergonomics
 
4:47 PM
@DenysSéguret maybe
self.display_img = None;
&self.display_img.get_or_insert(blah).img
now, get_or_insert does
    match *self {
        Some(ref mut v) => v,
        // SAFETY: a `None` variant for `self` would have been replaced by a `Some`
        // variant in the code above.
        None => unsafe { hint::unreachable_unchecked() },
    }
So you could use the same thing to make an
Option::set(&mut self, T) -> &mut T
you could add that locally or propose a PR to rust
 
5:43 PM
> It seems like thread::sleep is stalling. I believe this is because I've used 2 different time horizons and one seems to stall more than the other, all other things the same.
This is very close to bot-generated text to me ^_^
T I M E H O R I Z O N
 
5:56 PM
I'm blind. I looked for a function like get_or_insert_with and didn't find it :(
Hum... in fact I'd also need the filtering part for a good cache managing function
 
@DenysSéguret "the filtering part"?
 
It's for a cache:
        let cached = self.display_img.as_ref()
            .filter(|ci| ci.target_width==target_width && ci.target_height==target_height);
        let img = match cached {
            Some(ci) => &ci.img,
            None => {
                let img = expensive computation
                self.display_img = Some(CachedImage {
                    target_width,
                    target_height,
                    img,
                });
                &self.display_img.as_ref().unwrap().img
            }
filtering = conditional cache invalidation
 
That's how I did something similar.
I needed async world, so I wrote it myself
but you can do the same idea
value = value.take().filter();
value.get_or_insert_with();
 
I see. You do a take and then you reset the value. I didn't think about that. Conceptually I find it a little inelegant to always write the cache when it didn't change, though.
(but using unwrap isn't really elegant either)
 
6:20 PM
yep.
Again, you could make a method that does it
Option::filter_in_place(&mut self, impl FnMut(...))
 
yes
It's quite interesting that there is a get_or_insert but no insert (also returning a reference)
 
indeed!
You got any PRs to Rust yet?
If not, it may be time!
 
I'll add that to the list
But I'm afraid I'd find it difficult to find the whole procedure to follow ^^
A good argument against such method is that there are already many methods on Option and it becomes increasingly harder to scan them all in the doc
!!afk time for the kids to go to bed
 
6:49 PM
thanks
 
7:06 PM
DICOM-rs 0.3.0 is out! ^_^
 
/me doesn't find the changelog of DICOM-rs
 
link (yes, I used GitHub releases, fight me)
 
That looks big. But I know nothing about DICOM or the surrounding field...
 
It's a semver-incompatible release, so you "want" big
 
Not to mention that DICOM is huge too.
And I haven't yet tackled so many important pieces of it.
 
7:11 PM
Is it async yet?
/s
 
122 GH stars for a lib specific to a special field. This is amazing. Are there so many people developing DICOM related Rust applications ?
 
@Shepmaster It's under review in my roadmap.
I mean, it makes sense to consider, but at this point I am interested in tackling other concerns before delving into that world.
 
@DenysSéguret all bots paid for with that cash @E_net4changesdisplayname makes
 
@DenysSéguret My perspective on the subject is "not yet", but there is legitimate interest.
@Shepmaster Nope, I spent my bot money on toilet paper.
 
7:53 PM
Anybody I should r? if I do a PR for the Option thingie ?
 
8:03 PM
It should get auto-assigned reasonably
 
ok
I launched the compilation of broot and rustc at the same time. Like 15 minutes ago. Why did I say I'll release broot tonight ?
 
@DenysSéguret control-z is at hand.
 
The fact that I compile for 5 different platforms for the official release doesn't help
(thankfully I didn't manage to build for darwin)
yeah, broot finished first
 
8:33 PM
"surprise"
 
broot 1.0.1 released with a changelog
 
@DenysSéguret 1.0.**1**? Why not just get it right with 1.0.0?
 
no bug fix almost no bug fixes
 

« first day (2178 days earlier)      last day (1304 days later) »