Giter VIP home page Giter VIP logo

const-arrayvec's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

const-arrayvec's Issues

Almost Unsoundness bug :)

I was sure this was an unsoundness bug but right before I posted I realized it's actually not, but still needs changing IMHO.

try_insert() checks if the index is bigger then the len index > self.len(), otherwise panics.
https://github.com/Michael-F-Bryan/const-arrayvec/blob/master/src/lib.rs#L241:L270

Right now it also has a check if the array full, which in my opinion should be removed (you should still be able to insert something on index 2 in a [T; 8] array even if it's full).
BUT removing that check will right now introduce an unsoundness bug, because then you could pass index = len and it will write out of bound.

the check should be index >= self.len() because doing [1u8; 8][8] is obviously out of bound and should panic per rust's semantics.

Why?

Is there some reason why <T, const N: usize> might be preferable to <[T; N]>? If const generics worked, then anything doable with the former should already be doable with [T; N], no? And [T; N] works out more ergonomic normally, no?

Normalize method naming/behavior

I like the distinction between try_insert() and insert(). Along those lines, would it make sense for the current push() to become try_push(), and implement push() something like the below?

pub fn push(&mut self, item: T) {
    match self.try_push(item) {
        Ok(_) => {},
        Err(e) => panic!("Push failed: {}", e),
    }
}

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.