▲ 2 r/foss

Any program to measure one's voice pitch?

I need to measure my voice's hertz, i haven't found anything that's FOSS. As you all understand, i refuse to use something that might violate my privacy or bombard me with ads.

I heard that there are plugins to FOSS software like Audacity but that's very overkill for something so simple (i presume).

reddit.com
▲ 24 r/rust

Is there a macro for adding padding to a struct?

So when i want to add padding I just do this:

struct FooPadded {
    foo: Foo,
    _padding: [u8; 67],
}

But I hate this so much and it's uncomfortable. Fields are always important, so adding a useless field feels wrong. And confusing too, because when i see _padding i'm subconsciously expecting it to have a use, but no.

Is there a macro for adding padding? Something like this:

#[derive(PaddingMacroThing)]
struct FooPadded {
    foo: Foo,
    #[padding(67)]
}

Or when you want padding in multiple places:

struct FooBarPadded {
    #[padding(32)]
    bar: Bar,
    #[padding(4)]
    foo: Foo,
    #[padding(64)]
}

Is there anything like this? If not, at least anything that will ease the pain?

reddit.com
u/NormalAppearance2851 — 13 days ago
▲ 9 r/rust

What are some must-use crates for a "healthier" codebase?

I am trying to learn to write good Rust code, as one of my goals is to create or contribute to open-source projects.

I struggle a lot with designing a good codebase.

  • Lots of boilerplate
  • Not easy to write or read
  • Bad or not ideal performance
  • Inflexible
  • Too big or divided into too many submodules

As my coding journey goes, i stumble upon some crates that solve many problems i face. For example i have heard of derive_more and enum_dispatch, but i read that many people discourage people from using them.

Generally speaking: what are some must-use crates?

Now more specifically, currently i'm working on an AST for the luau programming language. While it's pretty much done and usable for constructing the AST and producing luau code, i could probably use some crate or two to make the codebase easier to work with and make developing it easier. I'm also planning to work on similar crates for like

  • formatting
  • parsing
  • a lexer

Specifically speaking: What crates do you recommend for these projects?

reddit.com
u/NormalAppearance2851 — 24 days ago
▲ 161 r/rust

Is .boxed() instead of Box::new() a bad idea?

So I started using this on all of my projects

pub trait Boxed: Sized {
    fn boxed(self) -> Box<Self>;
}

impl<T> Boxed for T
where T: Sized
{
    fn boxed(self) -> Box<Self> {
        Box::new(self)
    }
}

So instead of

let box = Box::new(10);

I do

let box = 10.boxed();

And IMO it shines when you do method chaining

let box = Box::new( // 🤓
  value
  .method_1()
  .method_2()
  .method_3()
);

let box =   value // 🗿
  .method_1()
  .method_2()
  .method_3()
  .boxed()

This seems great. But is it? When I got the idea i first searched for crates that do this for you, but I didn't find any. If there aren't any then does this mean that this is a terrible idea?

I think it's great. But I'm only a beginner so I don't know best.

EDIT:

Thank you everyone for the great and diverse feedback. I have taken into consideration a lot of things. This is my takeaway for more intuitive, explicit and readable code:

  • .boxed() isn't the best name, and .into_box() or something would be better.
  • Using the Pipe trait (from tap) would be way better value.pipe(Box::new) // 🗿value.boxed() // 🤡
  • Just using Box::new lol
  • .boxed() would possibly conflict with other crates

Imma start rewriting my code now 👋 I really like the pipe method.

reddit.com
u/NormalAppearance2851 — 29 days ago

Asahi Linux no longer boots?

So, like usual, i go to startup options and i select Fedora. But this time instead of booting into linux, it boots into macos?

Some info:

  • I haven't used Asahi Linux in a while
  • I recently updated Macos to Tahoe

Tbh I wouldn't mind uninstalling and reinstalling it. But is there another way perhaps?

reddit.com
u/NormalAppearance2851 — 1 month ago

Amazfit Helio Strap battery replacement?

If i ever need to replace the battery, can i do so? Is it repairable? If so do i order the part from amazfit? Can i buy the part from anywhere else?

I'm thinking of buying a Helio Strap and this is a concern for me. Thank you.

reddit.com
u/NormalAppearance2851 — 1 month ago
▲ 3 r/ugly

I really hate to use this word "ugly", but this is the term y'all use, so.

Online I see ugly men and women crying about how they never had or never will have a romantic relationship. I mean, did you try someone, "ugly"?

I see many unattractive people succeed in dating and socialisation. Just walking on the street shows this.

I'm posting this, because, i don't get why y'all deem it impossible and "unworthy??"? Are you saying that those couples aren't actually happy, or that they will break up eventually or something along those lines? Ok if you consider yourself loyal and loving, don't you think that there's a person that thinks the same way as you?

reddit.com
u/NormalAppearance2851 — 2 months ago
▲ 66 r/rust

So, what if we had something like a struct, but its methods borrow the fields instead of the whole thing?

AFAIK the community has asked for something like this but i've heard that

  • It's very hard to implement
  • It would break compatibility and stuff
reddit.com
u/NormalAppearance2851 — 2 months ago