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
    ubnt-intrepid (ubnt_intrepid@mstdn.maud.io)'s status on Monday, 16-Oct-2023 12:58:58 JST ubnt-intrepid ubnt-intrepid

    変数のmutabilityを初期化時に抑えたいときは

    ```rust
    let map = {
    let mut map = HashMap::new();
    map.insert("foo", bar);
    ...
    map
    };
    ```

    と書くほうが個人的には好み。あとは

    ```rust
    let mut make_id = {
    let mut next_id = 0;
    move || {
    let current_id = next_id;
    next_id += 1;
    current_id
    }
    };
    let i = make_id();
    let j = make_id();
    ...
    ```

    みたいなパターンも多用しがち

    In conversation Monday, 16-Oct-2023 12:58:58 JST from mstdn.maud.io permalink
    • Embed this notice
      ubnt-intrepid (ubnt_intrepid@mstdn.maud.io)'s status on Monday, 16-Oct-2023 12:58:57 JST ubnt-intrepid ubnt-intrepid
      in reply to
      • ドッグ

      @Linda_pp その場合はしゃあなしですね…

      In conversation Monday, 16-Oct-2023 12:58:57 JST permalink
    • Embed this notice
      らりお・ザ・何らかの🈗然㊌ソムリエ (lo48576@mastodon.cardina1.red)'s status on Monday, 16-Oct-2023 12:58:57 JST らりお・ザ・何らかの🈗然㊌ソムリエ らりお・ザ・何らかの🈗然㊌ソムリエ
      in reply to
      • かき@GNUsocialJP
      • ドッグ

      @ubnt_intrepid @Linda_pp その場合だと

      ```
      let (m, x) = {
      let mut m = ...;
      let x = ...;
      //
      (m, x)
      };
      ```

      みたいにすることが多いです。冗長になるので早々に関数にしたくなりますが…… (まあ関数にできるならそれはそれでリファクタリングとして正しいので良い)

      In conversation Monday, 16-Oct-2023 12:58:57 JST permalink
    • Embed this notice
      ドッグ (linda_pp@mstdn.jp)'s status on Monday, 16-Oct-2023 12:58:58 JST ドッグ ドッグ
      in reply to
      • らりお・ザ・何らかの🈗然㊌ソムリエ

      @ubnt_intrepid @lo48576 それもよくやるんですが

      let m = {
      let mut m = ...;
      let x = ...;
      m
      };

      // この辺りで x も使いたくなる

      みたいなことが結構あります

      In conversation Monday, 16-Oct-2023 12:58:58 JST 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.