arcmut 0.1.0

Introduce ArcMut, utility for FFI.
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented3 out of 4 items with examples
  • Size
  • Source code size: 64.01 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.24 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 24s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • al8n/arcmut
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • al8n

Introduce ArcMut struct, utility for FFI.

English | 简体中文

Introduction

ArcMut is a reference-counted pointer to a value of type T, which can be mutated.

Note: This struct is not thread-safe!!!

In normal Rust code, you are not expected to use this type, but when you are writing FFI code, you may need to use this type to share a value between Rust and other languages, and again, if the code in other languages is concurrent, you are encouraged to use a Arc<Mutex<T>> instead.

ArcMut<T> provides shared ownership of a value of type T, allocated in the heap. Invoking clone on ArcMut produces another pointer to the same allocation in the heap. When the last ArcMut pointer to a given allocation is destroyed, the value stored in that allocation (often referred to as "inner value") is also dropped.

This is similar to std::sync::Arc, but it allows interior mutability.

Installation

[dependencies]
arcmut = "0.1"

License

arcmut is under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

Copyright (c) 2024 Al Liu.