Git Product home page Git Product logo

tinyvec's Introduction

License:Zlib Minimum Rust Version crates.io docs.rs

Unsafe-Zero-Percent

tinyvec

A 100% safe crate of vec-like types. Not just safe at the public API boundary, fully safe for all internal code too: #![forbid(unsafe_code)]

The provided types are as follows:

  • ArrayVec is an array-backed vec-like data structure. It panics on overflow.
  • SliceVec is similar, but using a &mut [T] as the data backing.
  • TinyVec (alloc feature) is an enum that's either an Inline(ArrayVec) or a Heap(Vec). If a TinyVec is Inline and would overflow its array it automatically transitions to Heap and continues whatever it was doing.

To attain this "100% safe code" status there is one compromise: the element type of the vecs must implement Default.

For more API details, please see the docs.rs documentation

tinyvec Alternatives?

Maybe you don't want to use tinyvec, there's other crates you might use instead!

  • arrayvec is a crate with array-backed structures.
  • smallvec is a crate where the array-backed data can be moved to the heap on overflow.

The main difference is that both of those crates use unsafe code. This mostly allows them to get rid of the Default limitation for elements that tinyvec imposes. The smallvec and arrayvec crates are generally correct, but there's been occasional bugs leading to UB. With tinyvec, any uncaught bugs can't lead to UB, because the crate is safe code all the way through. If you want that absolute level of assurance against UB, use tinyvec.

tinyvec's People

Contributors

andylizi avatar c410-f3r avatar cryptjar avatar cuviper avatar dhardy avatar e00e avatar eeeebbbbrrrr avatar elomatreb avatar heroickatora avatar jakubadamw avatar jeffa5 avatar lokathor avatar madsmtm avatar maulingmonkey avatar mental32 avatar mgostih avatar mrcnski avatar msmorgan avatar nemo157 avatar notgull avatar repnop avatar rozaliev avatar saethlin avatar schubart avatar sd2k avatar shnatsel avatar slightlyoutofphase avatar soveu avatar striezel avatar thatsnomoon avatar

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.