mastodon.cardina1.red は、数々の独立したMastodonサーバーのうちのひとつです。サーバーに登録してFediverseのコミュニティに加わってみませんか。

サーバーの情報

3
人のアクティブユーザー

らりお・ザ・何らかの🈗然㊌ソムリエ

mstdn.nere9.help/@orange_in_sp

これ、

impl Hoge {
fn hoge1(self) -> Self;
fn hoge2(&self) -> &Self;
fn hoge3(&mut self) -> &mut Self;
fn hoge4(&mut self) -> Self;
// などなど
}

のどれのつもりで言ってるのかわからないんですが (これらが区別できない言語はまず弱い)

mstdn.nere9.helporange (@orange_in_space@mstdn.nere9.help)orange

C++ で言うなら、

struct Hoge {
const Hoge &hoge1() const;
Hoge &hoge2() const;
Hoge hoge3() const;
const Hoge &hoge4();
Hoge &hoge5();
Hoge hoge6();
};

くらいの使い分けはできるわけで、たとえば hoge4,5,6 が自身を変更するであろうというのは明らかだし、 hoge1,2 が自身か自身の所有するオブジェクトの参照を返すだろうというのも明らかですよね、そして hoge3 は自身のコピーか別オブジェクトを返す (いずれにせよ所有権は別になりそう) というのもわかる