linked_list_c

Crates.iolinked_list_c
lib.rslinked_list_c
version0.1.2
sourcesrc
created_at2022-12-22 23:51:19.045667
updated_at2023-03-05 02:02:22.413335
descriptionSafely work with c compatible linked lists
homepage
repositoryhttps://github.com/Will-Shanks/linked_list_c-rs
max_upload_size
id744177
size16,060
Will (Will-Shanks)

documentation

README

linked_list_c

This is a Rust crate with the goal of making C style linked lists easier to work with.

Some FFIs accept and/or return linked lists, requiring pointer wrangling and unsafe code to handle. This crate tries to take care of those ugly bits for you, and provide a safe and ergonomic interface instead

Features

  • Easily create Lists that can be passed to C FFIs
  • Safely iterate over a linked list received from a C FFI
  • handles cleaning up List on drop
    • can set a custom drop function if Drop, or libc::free() doesn't work for you
  • extremely simple trait is all thats neccessary to use with your favorite struct
    • just add #[derive(LlItem)] if yourStruct.next points to the next yourStruct
    • or use the impl_LlItem!([yourStruct, ...]) macro
  • Zero copy and minimal extra memory footprint (besides from<Vec> impl)
  • currently not quite no_std, but this could easily be made possible
Commit count: 18

cargo fmt