Giter Site home page Giter Site logo

enum-ptr's Introduction

Hi, it's QuarticCat

Projects

  • detypify: Typst symbol classifier
  • paguroidea: A reimplementation of the Flap parser in Rust

Notable Contributions

  • difftastic (#393, #395, #401, blog)
    Wrote a bunch of optimizations, boosting it by 4x. (partially merged)
  • lalrpop (#814)
    Rewrote the lexer, making the whole parsing process to be 2x~30x faster.
  • exllama (#275)
    Optimized the hottest CUDA kernel, gaining 20% speedup on 2070S and 10% speedup on 3090. (note it's already well optimized)

Interests

  • Algorithms and Data Structures
  • High Performance Computing
  • Functional Programming
  • ... (learning more)

Languages

  • Mostly: C++, Rust, Zsh
  • Sometimes: Python, Javascript, Haskell

Find Me On

Blog (en/zh) • Stack OverflowCodewarsTelegram Channel (zh)

enum-ptr's People

Contributors

quarticcat avatar

Stargazers

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

Watchers

 avatar  avatar

enum-ptr's Issues

Enum Ptr 0.2.0 Plan

  • Remove unit variant support and named variant support
  • Support generic type params
  • Change Aligned::Pointee to Aligned::ALIGNMENT
  • Support Rc and Arc
  • Rename feature std to alloc
  • Rename map_ref_mut to map_mut
  • Add abilities to use high bits
  • Add more methods to smooth user experience
  • Deal with the new discriminant value grammar

Return references from `map_ref` ?

Hi, thank you for making this crate.
I'd find it very useful to return refernces from map_ref, like this:

struct Bar {
    inner: u32,
}

#[derive(EnumPtr)]
#[repr(C, usize)]
enum Foo {
    A(Box<Bar>),
    B(Box<u64>),
}

let boxed = Foo::A(Box::new(Bar { inner: 1u32 }));
let compact_box: Compact<Foo> = boxed.into();

let reference = compact_box.map_ref(|foo| match foo {
    Foo::A(a) => &a.inner,
    Foo::B(_) => todo!(),
});

assert_eq!(*reference, 1u32);

I don't know if this is possible to achieve without UB, but it would be nice for sure.

Soundness issue of `map_ref_mut`

Consider foo.map_ref_mut(|f| *f = new_f), it will drop the old f. If the old f contains a Box, it will cause a double-free issue. Even f is trivially droppable, the modification won't be applied to foo, the compact f. We need to find a way to prevent users from modifying f itself or mark this function as unsafe or invent a new API to replace it.

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.