struct BuiltinFunction<F, A> {
_f, PhantomData<F>, _a: PhantomData<A>
}
で表現できそう
Fは関数定義を表す構造体でAは引数を表す構造体
let result = BuiltinFunction::<Hoge, HogeArgs>::invoke()?;
みたいにできる
struct BuiltinFunction<F, A> {
_f, PhantomData<F>, _a: PhantomData<A>
}
で表現できそう
Fは関数定義を表す構造体でAは引数を表す構造体
let result = BuiltinFunction::<Hoge, HogeArgs>::invoke()?;
みたいにできる
PhantomData<&'a()>
こう!!!
なるほど型無しなので () で良いのね…
PhantomData<&'a()>
こう!!!
なるほど型無しなので () で良いのね…
[Hoge<Foo>, Hoge<Bar>, Hoge<Baz>]
はそれぞれ型違うからだめでしょ!はい…などとやっていた
[Hoge<Foo>, Hoge<Bar>, Hoge<Baz>]
はそれぞれ型違うからだめでしょ!はい…などとやっていた
Fantastic deep dive from Fillmore Labs on how Rust optimizes type safety at compile time.
👉 blog.fillmore-labs.com/posts/zerosi...
#rust #systemsprogramming
Fantastic deep dive from Fillmore Labs on how Rust optimizes type safety at compile time.
👉 blog.fillmore-labs.com/posts/zerosi...
#rust #systemsprogramming
Why does it matter? Because sometimes, the strongest tools are invisible.
My new story breaks it down:
🔗 medium.com/@ashishjshar...
#Rust #SystemsProgramming #ZeroCost #PhantomData
Why does it matter? Because sometimes, the strongest tools are invisible.
My new story breaks it down:
🔗 medium.com/@ashishjshar...
#Rust #SystemsProgramming #ZeroCost #PhantomData
It's used to give the type system more knowledge without requiring any runtime memory.
Do you have any favorite uses of PhantomData?
It's used to give the type system more knowledge without requiring any runtime memory.
Do you have any favorite uses of PhantomData?
The PR covers high level overview of all changes. For detailed walk through, stay tuned for more blog posts and updates on the book.
The PR covers high level overview of all changes. For detailed walk through, stay tuned for more blog posts and updates on the book.
Hope it helped you learn 1% more Rust today, follow me for more threads like this 🦋 🦀
Hope it helped you learn 1% more Rust today, follow me for more threads like this 🦋 🦀
While Grade struct is 4 bytes (f32), the PhantomData itself takes up no space. It's just a compile-time type marker with no overhead! 🚀
While Grade struct is 4 bytes (f32), the PhantomData itself takes up no space. It's just a compile-time type marker with no overhead! 🚀
The code using phantom data will look something like this.
The code using phantom data will look something like this.
Ever wondered how to create a type that depends on another type but doesn't actually contain it?
Let's explore PhantomData with a practical example of a course grading system! 👇 🧵
Ever wondered how to create a type that depends on another type but doesn't actually contain it?
Let's explore PhantomData with a practical example of a course grading system! 👇 🧵