検索

phrase: max: clip:
target: order:
Results of 1 - 10 of about 16 for usize (0.021 sec.)
Final Code 14486
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... loc::heap; struct RawVec<T> { ptr: Unique<T>, cap: usize, } impl<T> RawVec<T> { fn new() -> Self { unsafe { ... // !0 is usize::MAX. This branch should be stripped at compile ti ... m::size_of::<T>(); // since we set the capacity to usize::MAX when elem_size is // 0, getting to here neces ... ; } } } } pub struct Vec<T> { buf: RawVec<T>, len: usize, } impl<T> Vec<T> { fn ptr(&self) -> *mut T { *sel ...
https://man.plustar.jp/rust/nomicon/vec-final.html - [similar]
サイズが 0 の型を扱う 10293
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... > RawVec<T> { fn new() -> Self { unsafe { // !0 は usize::MAX です。この分岐はコンパイル時に取り除かれるはず ... _of::<T>(); // elem_size が 0 の時にキャパシティを usize::MAX にしたので、 // ここにたどり着いてしまうという ... if mem::size_of::<T>() == 0 { ((slice.as_ptr() as usize) + slice.len()) as *const _ } else if slice.len() ... art = if mem::size_of::<T>() == 0 { (self.start as usize + 1) as *const _ } else { self.start.offset(1) }; ...
https://man.plustar.jp/rust/nomicon/vec-zsts.html - [similar]
PhantomData 9634
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... <T> { data: *const T, // *const for variance! len: usize, cap: usize, } Unlike the previous example, it app ... > { data: *const T, // *const for covariance! len: usize, cap: usize, _marker: marker::PhantomData<T>, } Ra ... キーワード: PhantomData , Vec , we , struct , type , usize , This , Iter , ライフタイム , variance ...
https://man.plustar.jp/rust/nomicon/phantom-data.html - [similar]
IntoIter 8889
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... いきます。 struct IntoIter<T> { buf: Unique<T>, cap: usize, start: *const T, end: *const T, } そしてこれが初期 ... set(1); Some(result) } } } fn size_hint(&self) -> (usize, Option<usize>) { let len = (self.end as usize - s ... elf.start as usize) / mem::size_of::<T>(); (len, Some(len)) } } そして ...
https://man.plustar.jp/rust/nomicon/vec-into-iter.html - [similar]
例外安全性 8646
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... らドロップまで、常に Some です elt: Option<T>, pos: usize, } impl<'a, T> Hole<'a, T> { fn new(data: &'a mut ... [T], pos: usize) -> Self { unsafe { let elt = ptr::read(&data[pos] ... , elt: Some(elt), pos: pos, } } } fn pos(&self) -> usize { self.pos } fn removed(&self) -> &T { self.elt.as ... _ref().unwrap() } unsafe fn get(&self, index: usize) -> &T { &self.data[index] } unsafe fn move_to(&mu ...
https://man.plustar.jp/rust/nomicon/exception-safety.html - [similar]
レイアウト 8560
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... とになります。 pub struct Vec<T> { ptr: *mut T, cap: usize, len: usize, } fn main() {} そして実際に、このコー ... e, self}; pub struct Vec<T> { ptr: Unique<T>, cap: usize, len: usize, } fn main() {} もしヌルポインタ最適化 ...
https://man.plustar.jp/rust/nomicon/vec-layout.html - [similar]
Drain 8491
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... on<T> { self.iter.next() } fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() } } impl<T ... on<T> { self.iter.next() } fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() } } impl<' ...
https://man.plustar.jp/rust/nomicon/vec-drain.html - [similar]
Subtyping and Variance 8317
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... derived from some parent scope fn foo(&'a str) -> usize; This signature claims that it can handle any &str ... &'a str , that would mean fn foo(&'static str) -> usize; could be provided in its place, as it would be a ... re: // 'a is derived from some parent scope fn foo(usize) -> &'a str; This signature claims that it will re ... therefore completely reasonable to provide fn foo(usize) -> &'static str; in its place. Therefore function ...
https://man.plustar.jp/rust/nomicon/subtyping.html - [similar]
Unsafe と連携する 8317
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... しょう。 #![allow(unused)] fn main() { fn index(idx: usize, arr: &[u8]) -> Option<u8> { if idx < arr.len() { ... しょう。 #![allow(unused)] fn main() { fn index(idx: usize, arr: &[u8]) -> Option<u8> { if idx <= arr.len() { ... みてください。 pub struct Vec<T> { ptr: *mut T, len: usize, cap: usize, } // この実装ではサイズが 0 の型を正し ...
https://man.plustar.jp/rust/nomicon/working-with-unsafe.html - [similar]
RawVec 8161
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... 与えます。 struct RawVec<T> { ptr: Unique<T>, cap: usize, } impl<T> RawVec<T> { fn new() -> Self { assert!( ... 更します。 pub struct Vec<T> { buf: RawVec<T>, len: usize, } impl<T> Vec<T> { fn ptr(&self) -> *mut T { *sel ... f.buf.ptr } fn cap(&self) -> usize { self.buf.cap } pub fn new() -> Self { Vec { buf: ...
https://man.plustar.jp/rust/nomicon/vec-raw.html - [similar]
PREV 1 2 NEXT