You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/irc.rs
+16-2Lines changed: 16 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,23 @@
6
6
//! The underlayer of `Irc` is Box, unlike `Arc` which wrap a hidden ArcInner on your inner types,
7
7
//! Irc use the same memory location of your inner types.
8
8
//!
9
-
//! [IrcItem::on_drop] in the trait allow you to have the ownship of underlying inner memory after the reference count of Irc is dropped.
9
+
//! # Benefits
10
10
//!
11
-
//! # Example
11
+
//! - No need to manual implementing the inc / dec on counter.
12
+
//!
13
+
//! - No enforced weak counter if you don't need it (every atomic op has cost).
14
+
//!
15
+
//! - [IrcItem::on_drop] in the trait allow you to have the ownship of underlying inner memory after the reference count of Irc is dropped. And you only need to define the drop behavior once, instead of write the same logic `Arc::into_inner` in every possible places (If forgetting so make your code block and hard to debug).
16
+
//!
17
+
//! - Using `Irc` to wrap a `Box`, no additional memory allocation and memory fragmentation, no
18
+
//! additional dereference cost (than using `Arc<Box<T>>`)
19
+
//!
20
+
//! - You can allocate a box from the time of its birth and wrap it will `Irc` for temporary usage, don't need to move bytes from / to stack. (especially when the inner object is large)
21
+
//!
22
+
//! - Advanced usage, multiple layer customized counter, on the same heap object, while preserving
0 commit comments