Struct std::boxed::BoxStable [-] [+] [src]

pub struct Box<T>(_);

A pointer type for heap allocation.

See the module-level documentation for more.

Methods

impl<T> Box<T>

fn new(x: T) -> Box<T>

Allocates memory on the heap and then moves x into it.

Examples

fn main() { let x = Box::new(5); }
let x = Box::new(5);

impl<T> Box<T> where T: ?Sized

unsafe fn from_raw(raw: *mut T) -> Box<T>

Constructs a box from the raw pointer.

After this function call, pointer is owned by resulting box. In particular, it means that Box destructor calls destructor of T and releases memory. Since the way Box allocates and releases memory is unspecified, so the only valid pointer to pass to this function is the one taken from another Box with box::into_raw function.

Function is unsafe, because improper use of this function may lead to memory problems like double-free, for example if the function is called twice on the same raw pointer.

Trait Implementations

impl<T> Default for Box<T> where T: Default

fn default() -> Box<T>

impl<T> Default for Box<[T]>

fn default() -> Box<[T]>

impl<T> Clone for Box<T> where T: Clone

fn clone(&self) -> Box<T>

Returns a new box with a clone() of this box's contents.

Examples

fn main() { let x = Box::new(5); let y = x.clone(); }
let x = Box::new(5);
let y = x.clone();

fn clone_from(&mut self, source: &Box<T>)

Copies source's contents into self without creating a new allocation.

Examples

fn main() { let x = Box::new(5); let mut y = Box::new(10); y.clone_from(&x); assert_eq!(*y, 5); }
let x = Box::new(5);
let mut y = Box::new(10);

y.clone_from(&x);

assert_eq!(*y, 5);

fn clone_from(&mut self, &Box<T>)

impl<T> PartialEq<Box<T>> for Box<T> where T: PartialEq<T>, T: ?Sized

fn eq(&self, other: &Box<T>) -> bool

fn ne(&self, other: &Box<T>) -> bool

fn ne(&self, &Box<T>) -> bool

impl<T> PartialOrd<Box<T>> for Box<T> where T: PartialOrd<T>, T: ?Sized

fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering>

fn lt(&self, other: &Box<T>) -> bool

fn le(&self, other: &Box<T>) -> bool

fn ge(&self, other: &Box<T>) -> bool

fn gt(&self, other: &Box<T>) -> bool

fn lt(&self, &Box<T>) -> bool

fn le(&self, &Box<T>) -> bool

fn gt(&self, &Box<T>) -> bool

fn ge(&self, &Box<T>) -> bool

impl<T> Ord for Box<T> where T: Ord, T: ?Sized

fn cmp(&self, other: &Box<T>) -> Ordering

impl<T> Eq for Box<T> where T: Eq, T: ?Sized

fn assert_receiver_is_total_eq(&self)

impl<T> Hash for Box<T> where T: Hash, T: ?Sized

fn hash<H>(&self, state: &mut H) where H: Hasher

fn hash_slice<H>(&[Box<T>], &mut H) where H: Hasher, Box<T>: Sized

impl BoxAny for Box<Any + 'static>

fn downcast<T>(self) -> Result<Box<T>, Box<Any + 'static>> where T: 'static

impl<T> Display for Box<T> where T: Display, T: ?Sized

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>

impl<T> Debug for Box<T> where T: Debug, T: ?Sized

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>

impl Debug for Box<Any + 'static>

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>

impl<T> Deref for Box<T> where T: ?Sized

type Target = T

fn deref(&self) -> &T

impl<T> DerefMut for Box<T> where T: ?Sized

fn deref_mut(&mut self) -> &mut T

impl<I> Iterator for Box<I> where I: Iterator, I: ?Sized

type Item = <I as Iterator>::Item

fn next(&mut self) -> Option<<I as Iterator>::Item>

fn size_hint(&self) -> (usize, Option<usize>)

fn size_hint(&self) -> (usize, Option<usize>)

impl<I> DoubleEndedIterator for Box<I> where I: DoubleEndedIterator, I: ?Sized

fn next_back(&mut self) -> Option<<I as Iterator>::Item>

impl<I> ExactSizeIterator for Box<I> where I: ExactSizeIterator, I: ?Sized

fn len(&self) -> usize

impl<'a, E> FromError<E> for Box<Error + 'a> where E: 'a, E: Error

fn from_error(err: E) -> Box<Error + 'a>

impl<'a> Reader for Box<Reader + 'a>

fn read(&mut self, buf: &mut [u8]) -> IoResult<usize>

fn read_at_least(&mut self, min: usize, buf: &mut [u8]) -> IoResult<usize>

fn read_byte(&mut self) -> IoResult<u8>

fn push(&mut self, len: usize, buf: &mut Vec<u8>) -> IoResult<usize>

fn push_at_least(&mut self, min: usize, len: usize, buf: &mut Vec<u8>) -> IoResult<usize>

fn read_exact(&mut self, len: usize) -> IoResult<Vec<u8>>

fn read_to_end(&mut self) -> IoResult<Vec<u8>>

fn read_to_string(&mut self) -> IoResult<String>

fn read_le_uint_n(&mut self, nbytes: usize) -> IoResult<u64>

fn read_le_int_n(&mut self, nbytes: usize) -> IoResult<i64>

fn read_be_uint_n(&mut self, nbytes: usize) -> IoResult<u64>

fn read_be_int_n(&mut self, nbytes: usize) -> IoResult<i64>

fn read_le_uint(&mut self) -> IoResult<usize>

fn read_le_int(&mut self) -> IoResult<isize>

fn read_be_uint(&mut self) -> IoResult<usize>

fn read_be_int(&mut self) -> IoResult<isize>

fn read_be_u64(&mut self) -> IoResult<u64>

fn read_be_u32(&mut self) -> IoResult<u32>

fn read_be_u16(&mut self) -> IoResult<u16>

fn read_be_i64(&mut self) -> IoResult<i64>

fn read_be_i32(&mut self) -> IoResult<i32>

fn read_be_i16(&mut self) -> IoResult<i16>

fn read_be_f64(&mut self) -> IoResult<f64>

fn read_be_f32(&mut self) -> IoResult<f32>

fn read_le_u64(&mut self) -> IoResult<u64>

fn read_le_u32(&mut self) -> IoResult<u32>

fn read_le_u16(&mut self) -> IoResult<u16>

fn read_le_i64(&mut self) -> IoResult<i64>

fn read_le_i32(&mut self) -> IoResult<i32>

fn read_le_i16(&mut self) -> IoResult<i16>

fn read_le_f64(&mut self) -> IoResult<f64>

fn read_le_f32(&mut self) -> IoResult<f32>

fn read_u8(&mut self) -> IoResult<u8>

fn read_i8(&mut self) -> IoResult<i8>

impl<'a> Writer for Box<Writer + 'a>

fn write_all(&mut self, buf: &[u8]) -> IoResult<()>

fn flush(&mut self) -> IoResult<()>

fn write(&mut self, buf: &[u8]) -> IoResult<()>

fn write_fmt(&mut self, fmt: Arguments) -> IoResult<()>

fn write_str(&mut self, s: &str) -> IoResult<()>

fn write_line(&mut self, s: &str) -> IoResult<()>

fn write_char(&mut self, c: char) -> IoResult<()>

fn write_int(&mut self, n: isize) -> IoResult<()>

fn write_uint(&mut self, n: usize) -> IoResult<()>

fn write_le_uint(&mut self, n: usize) -> IoResult<()>

fn write_le_int(&mut self, n: isize) -> IoResult<()>

fn write_be_uint(&mut self, n: usize) -> IoResult<()>

fn write_be_int(&mut self, n: isize) -> IoResult<()>

fn write_be_u64(&mut self, n: u64) -> IoResult<()>

fn write_be_u32(&mut self, n: u32) -> IoResult<()>

fn write_be_u16(&mut self, n: u16) -> IoResult<()>

fn write_be_i64(&mut self, n: i64) -> IoResult<()>

fn write_be_i32(&mut self, n: i32) -> IoResult<()>

fn write_be_i16(&mut self, n: i16) -> IoResult<()>

fn write_be_f64(&mut self, f: f64) -> IoResult<()>

fn write_be_f32(&mut self, f: f32) -> IoResult<()>

fn write_le_u64(&mut self, n: u64) -> IoResult<()>

fn write_le_u32(&mut self, n: u32) -> IoResult<()>

fn write_le_u16(&mut self, n: u16) -> IoResult<()>

fn write_le_i64(&mut self, n: i64) -> IoResult<()>

fn write_le_i32(&mut self, n: i32) -> IoResult<()>

fn write_le_i16(&mut self, n: i16) -> IoResult<()>

fn write_le_f64(&mut self, f: f64) -> IoResult<()>

fn write_le_f32(&mut self, f: f32) -> IoResult<()>

fn write_u8(&mut self, n: u8) -> IoResult<()>

fn write_i8(&mut self, n: i8) -> IoResult<()>

impl<R: Read + ?Sized> Read for Box<R>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<()>

fn read_to_string(&mut self, buf: &mut String) -> Result<()>

impl<W: Write + ?Sized> Write for Box<W>

fn write(&mut self, buf: &[u8]) -> Result<usize>

fn flush(&mut self) -> Result<()>

fn write_all(&mut self, buf: &[u8]) -> Result<()>

fn write_fmt(&mut self, fmt: Arguments) -> Result<()>

impl<S: Seek + ?Sized> Seek for Box<S>

fn seek(&mut self, pos: SeekFrom) -> Result<u64>

impl<B: BufRead + ?Sized> BufRead for Box<B>

fn fill_buf(&mut self) -> Result<&[u8]>

fn consume(&mut self, amt: usize)

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<()>

fn read_line(&mut self, buf: &mut String) -> Result<()>