Giter Club home page Giter Club logo

rodeo's Introduction

Rodeo

Rust Docs Rust Build Status Rust Nightly Build Status

A dropping untyped arena based on bumpalo:

  • arena: an allocator object that allows en masse deallocation
  • untyped: the same allocator object may be used to allocate any type, unlike typed_arena
  • dropping: any drop on the allocated data will be called, unlike bumpalo

⚠️ Warning

Rodeo only supports owned types for now.

Thanks to @TimNN and MIRI for pointing out my shortsightness.

Example

use rodeo::Rodeo;

struct S;
impl Drop for S {
    fn drop(&mut self) {
        println!("dropping S");
    }
}

{
    let rodeo = Rodeo::new();
    let n = rodeo.alloc(42);
    let r = rodeo.alloc(S);
}

prints dropping S

Features and #[no_std] Support

  • bumpalo (default)

    If not selected, you will have to plug your own allocator that implements the trait ArenaAlloc.

  • std (default)

    For now, rodeo is mostly a no_std crate. But std makes debugging a whole lot simpler!

You have to opt-out of bumpalo and std with default-features = false.

Safety

As a memory management library, this code uses unsafe extensively. However, the code is tested and dynamically verified with Miri.

Verification Strategy

Tests

Run the tests simply with:

cargo test

Miri

Miri is an interpreter for MIR (an intermediate representation of Rust) that checks Rust code and in particular unsafe code against the experimental Stacked Borrows memory model.

As of miri 0.1.0 (c1a859b 2022-11-10), Rodeo's tests show no error or warning when run with Miri.

rustup +nightly component add miri # if needed
cargo +nightly miri test
LEAK=1 cargo +nightly miri test # should leak two buffers

To-Do

  • add generic DST allocation, hide behind feature pending stabilization of Rust RFC 2580

  • investigate rodeo's use for self-referential structures

License

Rodeo is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-MIT and LICENSE-APACHE.

rodeo's People

Contributors

polazarus avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rodeo's Issues

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.