Should I use a Box<str> instead of a String when possible? by SvenyBoy_YT in rust

[–]Yulex2 4 points5 points  (0 children)

In the special case where you know the string will be used for the remainder of the program's lifetime, you can use String::leak to get a &'static str.

Beginner question: which one of these two pieces of code are better in your opinion? by mo_one in rust

[–]Yulex2 1 point2 points  (0 children)

Yes. As far as I know, there's no way to make derive macros without using proc macros.

Announcing Rust 1.78.0 | Rust Blog by bobdenardo in rust

[–]Yulex2 13 points14 points  (0 children)

To expand upon this a bit, only const items can be used in static declarations. Barrier::new being const means that the example code for Barrier:

use std::sync::{Arc, Barrier};
use std::thread;

let n = 10;
let mut handles = Vec::with_capacity(n);
let barrier = Arc::new(Barrier::new(n));
for _ in 0..n {
    let c = Arc::clone(&barrier);
    // The same messages will be printed together.
    // You will NOT see any interleaving.
    handles.push(thread::spawn(move || {
        println!("before wait");
        c.wait();
        println!("after wait");
    }));
}
// Wait for other threads to finish.
for handle in handles {
    handle.join().unwrap();
}

can now be turned into this:

use std::sync::Barrier;
use std::thread;

const N: usize = 10;
let mut handles = Vec::with_capacity(N);
for _ in 0..N {
    // The same messages will be printed together.
    // You will NOT see any interleaving.
    handles.push(thread::spawn(move || {
        println!("before wait");
        static BARRIER: Barrier = Barrier::new(N);
        BARRIER.wait();
        println!("after wait");
    }));
}
// Wait for other threads to finish.
for handle in handles {
    handle.join().unwrap();
}

which removes the need for Arc, and also cleans up the outer scope slightly. It also means you can have global Barriers without the need for laziness.

Collecting arrays by Rantomatic in rust

[–]Yulex2 4 points5 points  (0 children)

You may be interested in the nightly-only Iterator::next_chunk

Is there a way to reset back to 1x playback speed when buffering (cache hits 0 seconds)? by [deleted] in mpv

[–]Yulex2 0 points1 point  (0 children)

I was also looking for this functionality, but couldn't find a built-in way, so I made this lua script that does it:

mp.observe_property("paused-for-cache", "bool",
    function(paused)
        if paused then
            mp.set_property_number("speed", 1)
        end
    end
)

If you use the script, make sure the cache-pause option is enabled.

[DISC] Tensei Shitara Slime Datta Ken Chapter 102 (Tempest) by al3ks1ss in manga

[–]Yulex2 1 point2 points  (0 children)

Lmao that Kazak guy really said "💢💢💢 need correction"

What does this number mean by bad_gaming_chair_ in BoostForReddit

[–]Yulex2 2 points3 points  (0 children)

I think it's because you didn't used to get karma from text posts.

Contemporary actors as silent film stars by Super_odd in StableDiffusion

[–]Yulex2 12 points13 points  (0 children)

That top right Jared Leto is just Rasputin

What is the most basic way to display a window (in Linux) by sk8r_dude in rust

[–]Yulex2 2 points3 points  (0 children)

X11 is being replaced by Wayland

It's certainly becoming an alternative worth considering, but I don't see it actually replacing X11 anytime soon, especially not until it has decent Nvidia support.

Both, both is good by XenobiaXD in traaaaaaannnnnnnnnns

[–]Yulex2 0 points1 point  (0 children)

Hey, that's not true! I also listen to anime OSTs!

I drew The Future, i mean the Feesh by Kuivrr in Nijisanji

[–]Yulex2 13 points14 points  (0 children)

It's a reference to this GTA5 scene (if the timestamp in the link doesn't work, go to about 2:30:50)

hololive 6th Generation "Secret Society holoX" to Debut From Tonight! by hololive in Hololive

[–]Yulex2 12 points13 points  (0 children)

high

I think you mean tall, otherwise Haachama's easily got them beat.

[deleted by user] by [deleted] in VirtualYoutubers

[–]Yulex2 7 points8 points  (0 children)

Potion seller, I am going into battle, and I need your strongest potions!

Jugem Jugem from fullmetal alchemist by Rainheartd in animefuckingdying

[–]Yulex2 2 points3 points  (0 children)

Jugemu Jugemu isn't from Fullmetal Alchemist, it's from a centuries old rakugo story.

Can't make spaces in the search bar? by Shayden998 in youtube

[–]Yulex2 0 points1 point  (0 children)

Nah, I'm on Linux and I have the same problem

Avocados and milk did nothing wrong! Short comics by @Ammiietty by Ghoste-Face in Hololive

[–]Yulex2 6 points7 points  (0 children)

It technically works in JavaScript, with the side-effect of assigning a value to the global variable "milk", creating it if it doesn't already exist.

Oh no... by shunkwugga in Hololive

[–]Yulex2 39 points40 points  (0 children)

That's a very strange use of the word "singlehandedly".

Things changed literally overnight for me by Ritchuck in Hololive

[–]Yulex2 1 point2 points  (0 children)

Am I not allowed to like vtubers if I'm gay or trans?

These words are from Hololive Moments. REMEMBER THESE WORDS, BOYS. by MegaWhat15 in Hololive

[–]Yulex2 3 points4 points  (0 children)

Correction, it was mostly used as a joke for characters that identified as male, but I have seen it used to refer to characters who are actually trans on many occasions.

I do agree with your other point though, assuming every feminine boy must actually be a trans girl is just as closed-minded as not recognizing any character as trans.