Giter Club home page Giter Club logo

checked_array-rust's Introduction

BSD-2-Clause License MIT License docs.rs crates.io Download numbers dependency status Travis CI Appveyor CI

checked_array

This crate provides an API abstraction for array-like linear collections which exports checked APIs only.

Why checked_array

Rust's std::vec and std::slice modules have the problem, that they expose APIs which will implicitly panic if called with a wrong argument. Common examples are:

  • split_at*
  • rotate*
  • clone_from_slice
  • copy_from_slice
  • etc.

This is a problem because it does not only violate common design principles for safe languages like "explicit is better than implicit", but it is also not very typical for Rust itself, which usually provides fallible APIs using Option or Result.

checked_array tries to address this problem by defining checked APIs and providing an opaque generic wrapper which only implements these checked APIs.

checked_array and alloc

There is one exception to the safety guarantees of checked_array: if the wrapped type uses alloc/std::alloc, we cannot catch any allocation errors.

To make the user aware of this problem, we introduce the WillPanic error type if for wrapped types that will panic allocation errors.

checked_array-rust's People

Contributors

kizzycode avatar

Watchers

 avatar  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.