diff options
Diffstat (limited to 'core/zero_copy_buf.rs')
-rw-r--r-- | core/zero_copy_buf.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/zero_copy_buf.rs b/core/zero_copy_buf.rs index a458e12ff..a2625b8aa 100644 --- a/core/zero_copy_buf.rs +++ b/core/zero_copy_buf.rs @@ -6,8 +6,14 @@ use std::ops::DerefMut; /// A ZeroCopyBuf encapsulates a slice that's been borrowed from a JavaScript /// ArrayBuffer object. JavaScript objects can normally be garbage collected, /// but the existence of a ZeroCopyBuf inhibits this until it is dropped. It -/// behaves much like an Arc<[u8]>, although a ZeroCopyBuf currently can't be -/// cloned. +/// behaves much like an Arc<[u8]>. +/// +/// # Cloning +/// Cloning a ZeroCopyBuf does not clone the contents of the buffer, +/// it creates a new reference to that buffer. +/// +/// To actually clone the contents of the buffer do +/// `let copy = Vec::from(&*zero_copy_buf);` #[derive(Clone)] pub struct ZeroCopyBuf { backing_store: v8::SharedRef<v8::BackingStore>, |