Rustアンチスレ (202レス)
Rustアンチスレ http://mevius.5ch.net/test/read.cgi/tech/1509028624/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
143: デフォルトの名無しさん [sage] 2022/05/23(月) 09:11:41.94 ID:n2ZPTBPD // ヒープを使う型Testを作って実証実験 #[derive(Debug)] struct Test(Box<isize>); // Test型が作成される時に使われるnew()を実装 impl Test { fn new(n: isize) -> Self { let new = Test(Box::new(n)); // その時にヒープで確保されたアドレスを表示 println!("{:p} = Test::new({n})", new.0); new } } // Test型の足し算を実装 impl std::ops::Add for Test { type Output = Self; fn add(self, rhs: Self) -> Self::Output { Test::new(*self.0 + *rhs.0) } } // 足し算の途中で使われる一時領域のアドレスはどうなるか? fn main() { let a = Test::new(1); let b = Test::new(10); let c = Test::new(100); let d = Test::new(1000); let e = Test::new(10000); println!("{:?}", a + b + c + d + e); } http://mevius.5ch.net/test/read.cgi/tech/1509028624/143
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 59 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.004s