field-project

Crates.iofield-project
lib.rsfield-project
version0.1.0
sourcesrc
created_at2022-02-22 23:09:14.573659
updated_at2022-02-22 23:09:14.573659
descriptionField projection for all!
homepage
repositoryhttps://github.com/lachlansneff/field-project
max_upload_size
id537521
size9,323
Lachlan Sneff (lachlansneff)

documentation

README

field-project

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);
}
Commit count: 3

cargo fmt