lemmy.dudeami.win
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
testeronious@lemmy.world to Rust@programming.dev · 1 year ago

unfmt: A compile-time pattern matching library that reverses the interpolation process of format!.

github.com

external-link
message-square
9
fedilink
57
external-link

unfmt: A compile-time pattern matching library that reverses the interpolation process of format!.

github.com

testeronious@lemmy.world to Rust@programming.dev · 1 year ago
message-square
9
fedilink
GitHub - mathematic-inc/unfmt: A compile-time pattern matching library that reverses the interpolation process of `format!`.
github.com
external-link
A compile-time pattern matching library that reverses the interpolation process of `format!`. - mathematic-inc/unfmt
  • onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    4
    ·
    1 year ago

    What am I missing? Seems like it just puts the parameter in Some?

    Anti Commercial-AI license

    • Ephera@lemmy.ml
      link
      fedilink
      arrow-up
      21
      ·
      edit-2
      1 year ago

      You must’ve read that wrong.

      The first example, but formatted differently:

      let value = "My name is Rho.";
      let result = unformat!("My {} is {}.", value);
      

      Now, result contains:

      Some(("name", "Rho"))
      

      …because the words “name” and “Rho” in value happened to be at the position of the {}-slots in the unformat!()-pattern.

      • onlinepersona@programming.dev
        link
        fedilink
        English
        arrow-up
        6
        arrow-down
        1
        ·
        1 year ago

        Oh yeah! Thanks. It’s been a long day.

        Anti Commercial-AI license

Rust@programming.dev

rust@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !rust@programming.dev

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits
  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 24 users / day
  • 95 users / week
  • 293 users / month
  • 2.86K users / 6 months
  • 1 local subscriber
  • 7.16K subscribers
  • 562 Posts
  • 3.05K Comments
  • Modlog
  • mods:
  • snowe@programming.dev
  • Ategon@programming.dev
  • EdTheLegendary@programming.dev
  • kahnclusions@programming.dev
  • torcherist@programming.dev
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org