Commit Graph

15 Commits

Author SHA1 Message Date
Clar Charr
550373b1f9 Direct conversions between slices and boxes. 2017-02-06 18:53:13 -05:00
Srinivas Reddy Thatiparthy
3fd0e4c7f2 rustfmt liballoc folder 2016-05-28 02:25:16 +05:30
Alex Crichton
cb343c33ac Fix warnings during tests
The deny(warnings) attribute is now enabled for tests so we need to weed out
these warnings as well.
2016-01-26 09:29:28 -08:00
Nick Cameron
1f1a1e6595 rustfmt: liballoc, liballoc_*, libarena 2015-11-24 11:23:17 +13:00
Nick Cameron
8f51c8d687 rustfmt liballoc 2015-09-24 10:00:54 +12:00
Ms2ger
532235be27 Use Box::into_raw rather than the deprecated boxed::into_raw in tests and documentation. 2015-06-26 22:29:40 +02:00
Niko Matsakis
30b2d9e764 Fallout in libstd: remove impls now considered to conflict. 2015-04-01 11:21:42 -04:00
Alex Crichton
f19e763e08 std: Stabilize the rest of Any/BoxAny
This commit stabilizes the following APIs:

* `TypeId::of` - now that it has an `Any` bound it's ready to be stable.
* `Box<Any>::downcast` - now that an inherent impl on `Box<Any>` as well as
  `Box<Any+Send>` is allowed the `BoxAny` trait is removed in favor of these
  inherent methods.

This is a breaking change due to the removal of the `BoxAny` trait, but
consumers can simply remove imports to fix crates.

[breaking-change]
2015-03-30 16:44:11 -07:00
Eduard Burtescu
e64670888a Remove integer suffixes where the types in compiled code are identical. 2015-03-05 12:38:33 +05:30
we
6a2bad3257 int/uint => isize/usize in liblibc/liballoc/libarena 2015-02-09 10:00:46 +03:00
bors
758a296e27 Auto merge of #21647 - alfie:suffix-medium, r=alexcrichton 2015-02-02 11:52:34 +00:00
Stepan Koltsov
5a722f8632 box: into_raw, from_raw functions
Functions are needed for safety and convenience.

It is a common pattern to use `mem::transmute` to convert between
`Box` and raw pointer, like this:

```
let b = Box::new(3);
let p = mem::transmute(b);
// pass `p` to some C library
```

After this commit, conversion can be written as:

```
let p = boxed::into_raw(b);
```

`into_raw` and `from_raw` functions are still unsafe, but they are
much safer than `mem::transmute`, because *raw functions do not
convert between incompatible pointers. For example, this likely
incorrect code can be successfully compiled:

```
let p: *mut u64 = ...
let b: Box<u32> = mem::transmute(p);
```

Using `from_raw` results in compile-time error:

```
let p: *mut u64 = ...
let b: Box<u32> = Box::from_raw(p); // compile-time error
```

`into_raw` and `from_raw` functions are similar to C++ `std::unique_ptr`
`release` function [1] and constructor from pointer [2].

[1] http://en.cppreference.com/w/cpp/memory/unique_ptr/release
[2] http://en.cppreference.com/w/cpp/memory/unique_ptr/unique_ptr
2015-02-01 20:15:44 +03:00
Alfie John
00a933f9ec More deprecating of i/u suffixes in libraries 2015-02-01 10:34:16 +00:00
Tobias Bucher
7f64fe4e27 Remove all i suffixes 2015-01-30 04:38:54 +01:00
Stepan Koltsov
ace2f09d3f alloc::boxed: enable test
Previously test was disabled due to `#[cfg(test)]` before `mod boxed`.
2015-01-20 23:57:56 +03:00