検索

phrase: max: clip:
target: order:
Results of 1 - 10 of about 21 for struct (0.047 sec.)
print.html 12346
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... い。Vec の実装に関するセクションをみてください。 pub struct Vec<T> { ptr: *mut T, len: usize, cap: usize, } // ... うにします。 例えば、 #![allow(unused)] fn main() { struct A { a: u8, b: u32, c: u16, } } この構造体は、メンバ ... のようになるでしょう。 #![allow(unused)] fn main() { struct A { a: u8, _pad1: [u8; 3], // `b` のアラインメント ... 定義を見てみましょう。 #![allow(unused)] fn main() { struct A { a: i32, b: u64, } struct B { a: i32, b: u64, } ...
https://man.plustar.jp/rust/nomicon/print.html - [similar]
PhantomData 12228
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... types or lifetimes are logically associated with a struct, but not actually part of a field. This most commo ... for &'a [T] is (approximately) defined as follows: struct Iter<'a, T: 'a> { ptr: *const T, end: *const T, } ... However because 'a is unused within the struct's body, it's unbounded . Because of the troubles t ... ed, unbounded lifetimes and types are forbidden in struct definitions. Therefore we must somehow refer to th ...
https://man.plustar.jp/rust/nomicon/phantom-data.html - [similar]
repr(Rust) 10604
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... うにします。 例えば、 #![allow(unused)] fn main() { struct A { a: u8, b: u32, c: u16, } } この構造体は、メンバ ... のようになるでしょう。 #![allow(unused)] fn main() { struct A { a: u8, _pad1: [u8; 3], // `b` のアラインメント ... 定義を見てみましょう。 #![allow(unused)] fn main() { struct A { a: i32, b: u64, } struct B { a: i32, b: u64, } ... 造体を見てみましょう。 #![allow(unused)] fn main() { struct Foo<T, U> { count: u16, data1: T, data2: U, } } さ ...
https://man.plustar.jp/rust/nomicon/repr-rust.html - [similar]
Drop Check 10164
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... d. Tuples aren't special in this regard; composite structures just don't guarantee their destruction order a ... the fields of built-in composites like tuples and structs. However, what about something like Vec? Vec has ... piler can't sufficiently reason about the actual destruction order of the contents of any type that implemen ... g pointers. Consider the following simple program: struct Inspector<'a>(&'a u8); fn main() { let (inspector, ...
https://man.plustar.jp/rust/nomicon/dropck.html - [similar]
借用の分割 10063
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... ードは今日動作します。 #![allow(unused)] fn main() { struct Foo { a: i32, b: i32, c: i32, } let mut x = Foo {a ... fn main() {} type Link<T> = Option<Box<Node<T>>>; struct Node<T> { elem: T, next: Link<T>, } pub struct Lin ... kedList<T> { head: Link<T>, } pub struct IterMut<'a, T: 'a>(Option<&'a mut Node<T>>); impl< ... は可変スライスです。 fn main() {} use std::mem; pub struct IterMut<'a, T: 'a>(&'a mut[T]); impl<'a, T> Iterat ...
https://man.plustar.jp/rust/nomicon/borrow-splitting.html - [similar]
デストラクタ 9184
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... _in_place, Unique}; use std::mem; use alloc::heap; struct Box<T>{ ptr: Unique<T> } impl<T> Drop for Box<T> { ... _in_place, Unique}; use std::mem; use alloc::heap; struct Box<T>{ ptr: Unique<T> } impl<T> Drop for Box<T> { ... mem::size_of::<T>(), mem::align_of::<T>()); } } } struct SuperBox<T> { my_box: Box<T> } impl<T> Drop for Su ... ですから、以下のような #![allow(unused)] fn main() { struct Boxy<T> { data1: Box<T>, data2: Box<T>, info: u32, ...
https://man.plustar.jp/rust/nomicon/destructors.html - [similar]
Final Code 8761
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... t}; use std::marker::PhantomData; use alloc::heap; struct RawVec<T> { ptr: Unique<T>, cap: usize, } impl<T> ... self.ptr as *mut _, num_bytes, align); } } } } pub struct Vec<T> { buf: RawVec<T>, len: usize, } impl<T> Vec ... ce::from_raw_parts_mut(self.ptr(), self.len) } } } struct RawValIter<T> { start: *const T, end: *const T, } ... ffset(-1) }; Some(ptr::read(self.end)) } } } } pub struct IntoIter<T> { _buf: RawVec<T>, // we don't actuall ...
https://man.plustar.jp/rust/nomicon/vec-final.html - [similar]
型変換 8422
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... 値を構築する方法です。 #![allow(unused)] fn main() { struct Foo { x: u32, y: u16, } struct Bar { a: u32, b: u1 ... , メモリ , Foo , 提供 , 実装 , チェック , サイズ , struct ...
https://man.plustar.jp/rust/nomicon/conversions.html - [similar]
Drain 8422
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... だけを実装しましょう。 use std::marker::PhantomData; struct Drain<'a, T: 'a> { // ライフタイムの制限を課す必要 ... ます。抽出しましょう。 #![allow(unused)] fn main() { struct RawValIter<T> { start: *const T, end: *const T, } ... す。 } そして IntoIter は以下のようになります。 pub struct IntoIter<T> { _buf: RawVec<T>, // これを扱うことは ... 楽に実装できます。 use std::marker::PhantomData; pub struct Drain<'a, T: 'a> { vec: PhantomData<&'a mut Vec<T> ...
https://man.plustar.jp/rust/nomicon/vec-drain.html - [similar]
RawVec 8000
はじめに 1. 安全と危険のご紹介 1.1. 安全と危険の相互作用 1.2. Unsafe と連携する 2. データレイアウ ... にアロケート、伸長そして解放のロジックを 与えます。 struct RawVec<T> { ptr: Unique<T>, cap: usize, } impl<T> ... } } } } そして Vec を以下のように変更します。 pub struct Vec<T> { buf: RawVec<T>, len: usize, } impl<T> Vec ... す } } 最終的に、本当に IntoIter が単純になります。 struct IntoIter<T> { _buf: RawVec<T>, // これを扱うことは ...
https://man.plustar.jp/rust/nomicon/vec-raw.html - [similar]
PREV 1 2 3 NEXT