• 0 Posts
  • 31 Comments
Joined 1 year ago
cake
Cake day: July 24th, 2023

help-circle

  • I was a bit apprehensive because rust has like a gazillion different function types but here it seems to work like just any other language with a HM type system.

    The fn(T)->R syntax works for functions without associated data, it discards details of the implementation and works like function pointers in C. This allows them to be copy and 'static.

    The other function types can have data with them and have more type information at compile time which allows them to be inlined.
    These functions each have their own unwritable type that implements the function traits (Fn(T)->R, FnMut(T)->R and FnOnce(T)->R) depending on their enclosed data.

    I hope I remembered everything right from this video by Jon Gjengset.






  • The new version seems to fix that since your comment was written, but it will stil panics if less than 2 samples are provided, unless the crate it wraps panics at an earlier point.

    let peak = buf
                .iter()
                .copied()
                .enumerate()
                .take(self.sample_count / 2)
                .max_by_key(|(_, s)| (s.abs() * 1000.0) as u32)
                .expect("to have at least 1 sample");
    





  • EVs only eliminate tail pipe pollution, otherwise they are more of the same.
    They are multi ton metal boxes rolling on rubber wheels over asphalt roads, often to transport a single person. The create the same amount of traffic and waste the same amount of land on parking. Due to their heavy battery and better acceleration they create more fine particulates of wheel rubber.

    EV are a Verkehrsrichtungsänderung, a Verkehrswende consists of trains and public transit.



  • Keyword reserving is always exciting.
    In this case it’s gen, which allows iterators build on the state machines currently powering async.

    Here is a contrived use case from me.
    It’s not as groundbreaking as async but it’s a convenience. And hey, you could write futures without the async/await keywords, but it’s easier with them