1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! This crate provides the `IntoPin` trait.
//! `IntoPin` can be used to wrap any type in a [`Pin`],
//! but is powerfull in creating coerced, pinned references.
//!
//! [`Pin`]: https://doc.rust-lang.org/nightly/std/pin/struct.Pin.html
//! # Examples
//! ```
//! #![feature(pin)]
//!
//! extern crate pinpoint;
//! use std::pin::Pin;
//! use pinpoint::IntoPin;
//!
//! let v = vec![1, 2, 3, 4, 5];
//!
//! let pinned_slice: Pin<&[u32]> = (&v).into_pin();
//! ```
//!
//! An example using generics:
//! ```
//! #![feature(pin)]
//!
//! extern crate pinpoint;
//! use std::pin::Pin;
//! use pinpoint::IntoPin;
//!
//! fn example<'a, P>(item: P)
//! where
//! P: IntoPin<&'a mut [u8]>
//! {
//! let mut pin = item.into_pin();
//!
//! pin.reverse();
//! }
//!
//! let mut v = vec![1, 2, 3, 4];
//! example(&mut v);
//! assert_eq!(v, [4, 3, 2, 1]);
//!
//! let mut b: Box<[u8]> = Box::new([4, 3, 2, 1]);
//! example(&mut b);
//! assert_eq!(*b, [1, 2, 3, 4]);
//! ```
//! # Features
//!
//! In order to use the `IntoPin` trait, this crate should be used with the feature `pinned` of this crate turned on.
//! In order to create a pinned slice containg Cell types from a Cell containing a slice, use the `slice_of_cells` feature of this crate.
pub use IntoPin;