• FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    8
    ·
    1 day ago

    So glad they made the sane move and fixed std::env::home_dir(). The previous situation of having it deprecated due to fairly insignificant reasons, while recommending an abandoned crate instead was just silly.

  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    9
    ·
    2 days ago

    Honestly, kind of most excited about std::env::home_dir() being fixed/undeprecated. That’s the kind of thing that some languages would leave unfixed for eternity, until half the community recommends not using the stdlib even for basic uses.

  • Bogasse@lemmy.ml
    link
    fedilink
    arrow-up
    7
    ·
    1 day ago

    The gen keyword is too much teasing, I know it’s not round the corner but I’m gonna explode 🥺

    • BB_C@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      1 day ago

      In case the wording tripped anyone, generators (blocks and functions) have been available for a while as an unstable feature.

      This works (playground):

      #![feature(gen_blocks)]
      
      gen fn gfn() -> i32 {
          for i in 1..=10 {
              yield i;
          }
      }
      
      fn gblock() -> impl Iterator<Item = i32> {
          gen {
              for i in 1..=10 {
                  yield i;
              }
          }
      }
      
      fn main() {
          for i in gfn() {
              println!("{i} from gfn()");
          }
          for i in gblock() {
              println!("{i} from gblock()");
          }
      }
      

      Note that the block-in-fn version works better at this moment (from a developer’s PoV) because rust-analyzer currently treats gfn() as an i32 value. But the block-in-fn pattern works perfectly already.