GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    mcc (mcc@mastodon.social)'s status on Monday, 30-Dec-2024 06:29:44 JST mcc mcc

    I wish there was an easier way in Rust to implement Default on a type by supplying an exemplar const value without having to like do the whole multiline impl fn dance

    In conversation about 6 months ago from mastodon.social permalink
    • Embed this notice
      Cassandra Granade 🏳️‍⚧️ (xgranade@wandering.shop)'s status on Monday, 30-Dec-2024 06:29:44 JST Cassandra Granade 🏳️‍⚧️ Cassandra Granade 🏳️‍⚧️
      in reply to

      @mcc That seems like something that should be doable with a macro, honestly. Surprised no one has written it yet...

      In conversation about 6 months ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Monday, 30-Dec-2024 06:33:38 JST mcc mcc
      in reply to
      • Cassandra Granade 🏳️‍⚧️

      @xgranade maybe someone has, crates.io is large

      In conversation about 6 months ago permalink

      Attachments


    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Monday, 30-Dec-2024 06:33:38 JST mcc mcc
      in reply to
      • Cassandra Granade 🏳️‍⚧️

      @xgranade rust has so much less copypaste than C but the places where the copypaste shows up are all surprising

      In conversation about 6 months ago permalink
    • Embed this notice
      Cassandra Granade 🏳️‍⚧️ (xgranade@wandering.shop)'s status on Monday, 30-Dec-2024 06:33:38 JST Cassandra Granade 🏳️‍⚧️ Cassandra Granade 🏳️‍⚧️
      in reply to

      @mcc There is an incoming feature, IIRC, for default field values in structs, that should reduce the copypaste, at least, but yeah. Seems like something that would have had a more ergonomic approach a while ago.

      In conversation about 6 months ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Monday, 30-Dec-2024 06:36:38 JST mcc mcc
      in reply to
      • Cassandra Granade 🏳️‍⚧️

      @xgranade default field values are not my preferred solution but it's something. does this trigger as part of derive(default) or what?

      In conversation about 6 months ago permalink
    • Embed this notice
      Cassandra Granade 🏳️‍⚧️ (xgranade@wandering.shop)'s status on Monday, 30-Dec-2024 06:36:38 JST Cassandra Granade 🏳️‍⚧️ Cassandra Granade 🏳️‍⚧️
      in reply to

      @mcc The language feature was approved with https://github.com/rust-lang/rfcs/pull/3681, and documents that yeah, #[derive(Default)] will work if every field has a default value or itself implements Default.

      From the RFC:

      ```
      #[derive(Default)]
      struct Pet {
      name: Option<String>, // impl Default for Pet will use Default::default() for name
      age: i128 = 42, // impl Default for Pet will use the literal 42 for age
      }
      ```

      In conversation about 6 months ago permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: opengraph.githubassets.com
        [RFC] Default field values by estebank · Pull Request #3681 · rust-lang/rfcs
        Allow struct definitions to provide default values for individual fields and thereby allowing those to be omitted from initializers. When deriving Default, the provided values will then be used. Fo...
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Monday, 30-Dec-2024 06:51:30 JST mcc mcc
      in reply to
      • Cassandra Granade 🏳️‍⚧️

      @xgranade ok. i think this doesn't piss me off the way C#/C++/Java do because there's no "default members AND a constructor" option.

      In conversation about 6 months ago permalink
    • Embed this notice
      Cassandra Granade 🏳️‍⚧️ (xgranade@wandering.shop)'s status on Monday, 30-Dec-2024 06:51:30 JST Cassandra Granade 🏳️‍⚧️ Cassandra Granade 🏳️‍⚧️
      in reply to

      @mcc It does seem in general as though the Rust RFC process has made it possible to learn from where other languages have made mistakes.

      In conversation about 6 months ago permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.