[][src]Function moite_moite::sync::split

pub fn split<L, R, W>(value: W) -> (Part<L, W>, Part<R, W>) where
    L: ?Sized,
    R: ?Sized,
    W: SplitMut<L, R>, 

Splits a value into two owned parts.

Sharing

The internal reference counter is atomic, allowing the left and right parts to be safely shared across threads:

  • Part<T, W> is Sync if T is Sync;
  • Part<T, W> is Send if T is Send and W is Send.

There are no W: Sync bounds because users cannot get a reference to a split W, whereas there is a W: Send bound because the dropping code for W may be run on any thread, when its last part is dropped.

Example

use moite_moite::sync;

let (mut left, right) = sync::split(("hello".to_owned(), "!".to_owned()));
left.push_str(", world");
assert_eq!(format!("{}{}", left, right), "hello, world!");