Code Monkey home page Code Monkey logo

ptr-to-field's Introduction

Pointer to Field

Note: This library is no long being worked on, please use generic-field-projection instead.

This workspace is a proof of concept for the pointer to field concept discussed in this Rust Internals discussion.

This workspace does not intend to be a fully fledged implementation, and will likely be missing many key features to making the pointer to field idea truly work.

Basic sketch of how this workspace workspace

#[repr(C)]           // This is required to have a stable layout so that we can create the correct field offsets
#[derive(Project)]   // This derive is given in the ptr-to-field-macro crate
struct Foo {
    pub names: String,
    bar: Bar,
}

It will give the following implementations

pub mod Foo_fields {
    use super::*;

    pub enum names {}

    unsafe impl ptr_to_field_core::Field for names {
        type Parent = Foo;
        type Type = String;

        const META: ptr_to_field_core::FieldMeta = unsafe {
            ptr_to_field_core::FieldMeta::new_unchecked(
                0
            )
        };
    }

    pub(super) enum bar {}

    unsafe impl ptr_to_field_core::Field for names {
        type Parent = Foo;
        type Type = Bar;

        const META: ptr_to_field_core::FieldMeta = unsafe {
            ptr_to_field_core::FieldMeta::new_unchecked(
                std::mem::size_of::<String>()
            )
        };
    }
}

Contributing

See CONTRIBUTING.md

ptr-to-field's People

Contributors

rustyyato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isgasho

ptr-to-field's Issues

Finish implementations of projections

Currently only a few projections are implemented, let's complete the list. Note, not all of these need to make it into the RFC, but they will provide some motivation for the RFC.

Fix example in README

currently the expansion of the Project macro in the README is wrong, need to fix it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.