ogoffart / vptr Goto Github PK
View Code? Open in Web Editor NEWLight references to trait objects by embedding the virtual table pointer in the struct
License: MIT License
Light references to trait objects by embedding the virtual table pointer in the struct
License: MIT License
This is a heads-up that the crate does not compile any more with the current Rust beta (to become stable Nov 7th). The reason is that there is UB in this const-code:
Line 125 in ca32aa4
References must always be non-null, dereferencable and aligned as well as point to a valid instance of T
(see the Rust Reference for details). Violating that invariant is UB, and it is the responsibility of the unsafe
code author to ensure that there is no UB.
Unfortunately, there never was a UB-free way to implement offsetof!
in Rust. This operation is just not supported by the language right now, and the only way to fix that is to figure out what needs to change in the language to let Rust support this operation, and write an appropriate RFC. I did that and that RFC has in fact recently been accepted, but an implementation is still pending.
The memoffset
crate uses an approach that's as good as we can currently make it, and we know it works with current compilers (including the latest nightly), but it could break any time as it, too, is outside the bounds of stable Rust. Also, the approach it uses does not work for CTFE; enabling that is still work-in-progress.
Is there a way for this crate to do the offset computation at run-time instead of trying to do it at compile-time? Then it could depend on memoffset
to avoid this problem. I'm afraid for compile-time offsetof
there is currently no solution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.