GithubHelp home page GithubHelp logo

Comments (2)

andylokandy avatar andylokandy commented on June 19, 2024

Thanks for bringing this up!

This is one of the limitations of smallbox now. You can't have a sized SmallBox with unsize feature flag on. The only formal solution is using CoerceUnsize, which can automatically coerce a sized StackBox into unsized one, or just keep it sized if coercion is not required. There is a problem on SmallBox that CoerceUnsize can't be implement for an enum. I also have a solution for it: Turn SmallBox into a struct and then track the tag information by ourselves. But it has a trade off that we have to define our own Box type to control the heap pointer, which means we would not be able to get a standard Box<T> out of it again.

I'd suggest exposing same basic interface for sized values via new and create a separate feature-controlled new_unsized for when it's needed, so that compiler can distinguish and correctly resolve types in both cases.

It definitely is a solution for the problem, I'll take it into consideration.

from smallbox.

andylokandy avatar andylokandy commented on June 19, 2024

CoerceUnsize is implemented for SmallBox and the new method only requires T: Sized now, so you can have either a sized SmallBox or an unsized SmallBox coerced from the sized one.

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.