GithubHelp home page GithubHelp logo

Comments (10)

andylokandy avatar andylokandy commented on July 1, 2024

AFAICS, there are some problems of the new macro:

  1. We have to expose private fields of Stackbox, but it would be unsafe behaviors to change any of it, and these operations do not require an unsafe block.

  2. It is not possible to use such macros in a crate with #![deny(unsafe_code)].

from smallbox.

RReverser avatar RReverser commented on July 1, 2024

I would say (2) doesn't matter as much. As for the first one - yeah, macro will have to use a method that, as similar macros usually do, can be hidden from docs for general consumers with #[doc(hidden)] but used by the macro itself.

from smallbox.

andylokandy avatar andylokandy commented on July 1, 2024

#[doc(hidden)] doesn't prevent crate user from invoking undefined behaviors or even segfaults. This problem is much more severe than phf_macro in which struct fields violation only causes control flow error. I prefer to stick with Unsize traits for type system guarantee for now.

from smallbox.

andylokandy avatar andylokandy commented on July 1, 2024

Stable unsize feature is no longer viable due to the CoerceUnsize commit cda7d6b.

from smallbox.

RReverser avatar RReverser commented on July 1, 2024

I still think unsized on stack is possible in a safe way on stable Rust, but if you feel strongly against this idea, it's fair point and I suppose I can implement it in a separate crate.

from smallbox.

andylokandy avatar andylokandy commented on July 1, 2024

Do you have any idea of how to do that?

I don't know how to resolve #7 in stable rust.

from smallbox.

andylokandy avatar andylokandy commented on July 1, 2024

Ok, I got it. The new_unsized method and the macro initializer. You might make a hard fork for that, it's good for the user to have more options.

from smallbox.

andylokandy avatar andylokandy commented on July 1, 2024

I've come up with an elegant solution about the macro story. I'll try it out soon.

from smallbox.

andylokandy avatar andylokandy commented on July 1, 2024

👏 👏 Stable unsized type is done!!! Thanks for your help!!

from smallbox.

RReverser avatar RReverser commented on July 1, 2024

@andylokandy Heh, I've been away for a week, but glad to see this got resolved!

from smallbox.

Related Issues (13)

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.