検索

phrase: max: clip:
target: order:
Results of 1 - 10 of about 19 for new (0.024 sec.)
RawVec 12328
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... r: Unique<T>, cap: usize, } impl<T> RawVec<T> { fn new() -> Self { assert!(mem::size_of::<T>() != 0, "TOD ... ment ZST support"); unsafe { RawVec { ptr: Unique::new(heap::EMPTY as *mut T), cap: 0 } } } // Vec の時と ... ::<T>(); let elem_size = mem::size_of::<T>(); let (new_cap, ptr) = if self.cap == 0 { let ptr = heap::all ... ocate(elem_size, align); (1, ptr) } else { let new_cap = 2 * self.cap; let ptr = heap::reallocate(*se ...
https://man.plustar.jp/rust/nomicon/vec-raw.html - [similar]
Final Code 12055
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... r: Unique<T>, cap: usize, } impl<T> RawVec<T> { fn new() -> Self { unsafe { // !0 is usize::MAX. This bra ... and "zero-sized allocation" RawVec { ptr: Unique::new(heap::EMPTY as *mut T), cap: cap } } } fn grow(&mu ... overflow"); let align = mem::align_of::<T>(); let (new_cap, ptr) = if self.cap == 0 { let ptr = heap::all ... ocate(elem_size, align); (1, ptr) } else { let new_cap = 2 * self.cap; let ptr = heap::reallocate(*se ...
https://man.plustar.jp/rust/nomicon/vec-final.html - [similar]
ドロップフラグ 10501
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... は、状況によらずドロップしません。 let mut x = Box::new(0); // let によって新しい変数が生成されるので、ドロ ... ップの必要はありません let y = &mut x; *y = Box::new(1); // 参照外しでは、参照される側の変数は初期化され ... す。 #![allow(unused)] fn main() { let mut x = Box::new(0); // x は初期化されていないので、単に上書きします ... します。そして x を初期化前の状態にします。 x = Box::new(0); // x は初期化されていないので、単に上書きします ...
https://man.plustar.jp/rust/nomicon/drop-flags.html - [similar]
サイズが 0 の型を扱う 10501
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... ードを書くことを意味します。 impl<T> RawVec<T> { fn new() -> Self { unsafe { // !0 は usize::MAX です。この ... の意味を兼ねることになります。 RawVec { ptr: Unique::new(heap::EMPTY as *mut T), cap: cap } } } fn grow(&mu ... overflow"); let align = mem::align_of::<T>(); let (new_cap, ptr) = if self.cap == 0 { let ptr = heap::all ... ocate(elem_size, align); (1, ptr) } else { let new_cap = 2 * self.cap; let ptr = heap::reallocate(*se ...
https://man.plustar.jp/rust/nomicon/vec-zsts.html - [similar]
アロケーティング 10228
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... く、 ptr にヌルポインタを代入出来ないとしたら、 Vec::new で何をすれば いいのでしょうか? そうだ、単純にそこに ... ::mem; use alloc::heap::EMPTY; impl<T> Vec<T> { fn new() -> Self { // まだ ZST を扱う準備が出来ていません ... す。 // 推論してもらいましょう。 Vec { ptr: Unique::new(heap::EMPTY as *mut _), len: 0, cap: 0 } } } } コー ... ::<T>(); let elem_size = mem::size_of::<T>(); let (new_cap, ptr) = if self.cap == 0 { let ptr = heap::all ...
https://man.plustar.jp/rust/nomicon/vec-alloc.html - [similar]
print.html 9049
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... gs: &'b [T]) -> &'a mut Command // 展開した場合 fn new(buf: &mut [u8]) -> BufWriter; // 省略した場合 fn n ... llowing code: fn overwrite<T: Copy>(input: &mut T, new: &mut T) { *input = *new; } fn main() { let mut fo ... es to two values of the same type, and overwrites one with the other. If &mut T was variant over T, then ... str> { // string literals are `&'static str`s Box::new("hello") } } Weakening when you pass by-value is f ...
https://man.plustar.jp/rust/nomicon/print.html - [similar]
Drop Check 8691
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... 8); fn main() { let (inspector, days); days = Box::new(1); inspector = Inspector(&days); } This program i ... } } fn main() { let (inspector, days); days = Box::new(1); inspector = Inspector(&days); // Let's say `da ... n>:10 let (inspector, days); <anon>:11 days = Box::new(1); <anon>:12 inspector = Inspector(&days); <anon> ... n>:10 let (inspector, days); <anon>:11 days = Box::new(1); <anon>:12 inspector = Inspector(&days); <anon> ...
https://man.plustar.jp/rust/nomicon/dropck.html - [similar]
競合 8042
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... / ライフタイムを必要とするからです! let idx = Arc::new(AtomicUsize::new(0)); let other_idx = idx.clone(); ... ::Arc; let data = vec![1, 2, 3, 4]; let idx = Arc::new(AtomicUsize::new(0)); let other_idx = idx.clone(); ...
https://man.plustar.jp/rust/nomicon/races.html - [similar]
コンストラクタ 7769
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... ストラクタに対して、このトレイトを実装する型が静的な new メソッドを 提供します。これは他の言語における new ... ません。 これはただの命名規則です。 TODO: "placement new" について話す? 関連キーワード: Copy , 実装 , メモリ ...
https://man.plustar.jp/rust/nomicon/constructors.html - [similar]
チェックされるメモリ 7683
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... い事になります。 fn main() { let x = 0; let y = Box::new(0); let z1 = x; // i32 は Copy を実装しているため、 ... と認識出来るからです。 fn main() { let mut y = Box::new(0); let z = y; // Box が Copy を実装していないため ... 、もはや y は論理的には初期化されていません y = Box::new(1); // y を再初期化します } そうでなければ、 y は全 ...
https://man.plustar.jp/rust/nomicon/checked-uninit.html - [similar]
PREV 1 2 NEXT