BB_C

joined 1 year ago
[–] [email protected] 1 points 1 day ago

In Rust, you provide a string — that is injected to be invoked internally. In C++, we’d just provide a callable.

This is because Rust’s attribute grammar can’t support a callable here.

I don't do C++ as a life choice, and thus not 100% sure what the author means here. But I have the feeling that he is wrong, on multiple levels even 😉

[–] [email protected] 3 points 3 days ago (1 children)

I just looked at the code, and it's actually a neat idea implementation wise, and I see now how it helped you.

But I'm still of the opinion that its a purpose mismatch.

[–] [email protected] 4 points 3 days ago (3 children)

Last week I basically duplicated the serialization code to provide better debug output…

Why was duplication needed, instead of implementing Debug using serialized output?

And why would one want to rename stuff...etc in Debug anyway? It's for debugging?

This looks like purpose mismatch to me.

[–] [email protected] 8 points 5 days ago

Also:

A short post on how variable names can leak out of macros

I don't think you understood the blog OP!

[–] [email protected] 1 points 1 week ago* (last edited 1 week ago) (3 children)

There is a general mechanism in Rust that allows language users to add their own sugar. It's called macros 😉

macro_rules! keep {
    (let $id:ident = $expr:expr => $($tt:tt)+) => {
        let $id = $expr;
        let $id = $id$($tt)+;
    }
}

fn main() {
    keep!{ let path = std::env::current_dir().unwrap() => .as_path() };
    println!("{path:?}");
}

You can remove let from the macro's fragment specifier and invocation.

[–] [email protected] -5 points 1 week ago

mastering_rust

Maybe wait until you're actually good at it.

[–] [email protected] 3 points 1 week ago

Rebinding with and without mut is a known and encouraged pattern in rust. Leaving things as mut longer than necessary is not.

[–] [email protected] 19 points 1 week ago (1 children)

Neither.

  • make new() give you a fully valid and usable struct value.
  • or use a builder (you can call it something else like Partial/Incomplete/whatever) struct so you can't accidentally do anything without a fully initialized value.

Maybe you should also use substructs that hold some of the info.

[–] [email protected] 8 points 2 weeks ago (2 children)

If you're not into tiling, install openbox and a panel of your choosing. You will quickly find that you don't need a DE at all.

[–] [email protected] 4 points 2 weeks ago (1 children)

The maintenance is too high.

acquired knowledge spotted

view more: next ›