Crates.io | field-project |
lib.rs | field-project |
version | 0.1.0 |
source | src |
created_at | 2022-02-22 23:09:14.573659 |
updated_at | 2022-02-22 23:09:14.573659 |
description | Field projection for all! |
homepage | |
repository | https://github.com/lachlansneff/field-project |
max_upload_size | |
id | 537521 |
size | 9,323 |
Generic projection for all types! This crate adds projection support, through the Project
trait and proj!
macro
to all types in Rust. No derive required!
use std::pin::Pin;
use field_project::proj;
struct Foo {
a: i32,
b: &'static str,
}
fn main() {
let foo = Box::pin(Foo { a: 42, b: "hello, world" });
let a: Pin<_> = proj!(foo.a);
let b = proj!(foo.b);
println!("a: {:?}, b: {:?}", a, b);
}