199 Commits

Author SHA1 Message Date
Casey Rodarmor
0d985c9e87 Reword OsStr docs to clarify that utf8 may contain nulls 2017-06-25 14:23:43 -07:00
Corey Farwell
93abc2f877 Add doc example for CString::from_raw. 2017-06-20 13:49:42 -04:00
Corey Farwell
d3c26fe7e3 Add doc example for FromBytesWithNulError. 2017-06-20 13:49:42 -04:00
Corey Farwell
4797d8446c Add doc example for NulError. 2017-06-20 13:49:42 -04:00
Corey Farwell
e52d2f2ad0 Add doc example for CStr::to_str. 2017-06-20 13:49:42 -04:00
Corey Farwell
0962394b84 Add doc example for CString::as_c_str. 2017-06-20 13:49:42 -04:00
Corey Farwell
65793b30d3 Add doc example for Box<CStr>::into_c_string. 2017-06-20 13:49:27 -04:00
Corey Farwell
db97145150 Add doc example for CString::into_boxed_c_str. 2017-06-20 13:49:27 -04:00
Corey Farwell
82ba871c70 Add doc example for CStr::to_string_lossy. 2017-06-20 13:49:27 -04:00
Corey Farwell
5d71e8cd7e Add error scenario doc examples for CStr::from_bytes_with_nul. 2017-06-20 13:49:27 -04:00
Corey Farwell
7f687f8602 Add doc example for CStr::to_bytes_with_nul. 2017-06-20 13:49:27 -04:00
Corey Farwell
0fad2e038a Add doc example for CStr::to_bytes. 2017-06-20 13:49:10 -04:00
Alexander Bulaev
bcb5b13b85 Mark smaller CStr and CString functions as #[inline] 2017-06-20 11:18:52 +03:00
Stepan Koltsov
ac96fd7787 Avoid allocations in Debug for os_str
Fixes #38879
2017-06-15 20:42:37 +01:00
Corey Farwell
06f63f5edb Add doc example for CString::as_bytes. 2017-06-05 23:50:49 -04:00
Corey Farwell
ae4832d48a Add doc example for CString::as_bytes_with_nul. 2017-06-05 23:49:52 -04:00
Corey Farwell
815c12a765 Add doc example for CString::into_bytes_with_nul. 2017-06-05 23:48:13 -04:00
Corey Farwell
3ec1f61acc Add doc example for CString::into_bytes. 2017-06-05 23:46:44 -04:00
Corey Farwell
4db8c9f0ba Add doc example for CString::into_raw. 2017-06-05 23:43:25 -04:00
Guillaume Gomez
55c3f0b12e Add missing urls for OsStr docs 2017-05-24 19:33:40 +02:00
Guillaume Gomez
819acb5141 Add missing links for CStr and CString 2017-05-22 23:23:27 +02:00
Clar Charr
6119f9856c Remove unused lifetimes. 2017-05-20 15:32:11 -04:00
Oliver Middleton
2f703e4304 Correct some stability versions
These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
2017-05-20 08:38:39 +01:00
Matt Brubeck
defcfb21f1 Remove wrong or outdated info from CString docs. 2017-05-09 10:55:47 -07:00
Scott McMurray
295bcdb715 Override ToOwned::clone_into for Path and OsStr
The only non-overridden one remaining is the CStr impl, which cannot
be optimized as doing so would break CString's second invariant.
2017-04-18 21:02:18 -07:00
bors
ebb10a6131 Auto merge of #41095 - clarcharr:as_extras, r=alexcrichton
Add as_c_str

Again, tying up some consistencies with `CString`.
2017-04-09 09:17:34 +00:00
Clar Charr
68909b0ec0 Add as_c_str. 2017-04-07 15:19:02 -04:00
Clar Charr
9ffb54568c Remove some CStr transmutes. 2017-04-06 17:42:02 -04:00
Corey Farwell
bc6eecd0c2 Merge branch 'master' into frewsxcv-osstr 2017-03-16 21:56:52 -04:00
bors
71d7b29475 Auto merge of #40009 - clarcharr:box_to_buf, r=alexcrichton
Leftovers from #39594; From<Box> impls

These are a few more impls that follow the same reasoning as those from #39594.

What's included:
* `From<Box<str>> for String`
* `From<Box<[T]>> for Vec<T>`
* `From<Box<CStr>> for CString`
* `From<Box<OsStr>> for OsString`
* `From<Box<Path>> for PathBuf`
* `Into<Box<str>> for String`
* `Into<Box<[T]>> for Vec<T>`
* `Into<Box<CStr>> for CString`
* `Into<Box<OsStr>> for OsString`
* `Into<Box<Path>> for PathBuf`
* `<Box<CStr>>::into_c_string`
* `<Box<OsStr>>::into_os_string`
* `<Box<Path>>::into_path_buf`
* Tracking issue for latter three methods + three from previous PR.

Currently, the opposite direction isn't doable with `From` (only `Into`) because of the separation between `liballoc` and `libcollections`. I'm holding off on those for a later PR.
2017-03-15 04:24:10 +00:00
Corey Farwell
6adbbfc6ba Add doc example for OsString::into_boxed_os_str. 2017-03-14 09:30:18 -04:00
Corey Farwell
bda57dbc05 Add doc example for OsString::shrink_to_fit. 2017-03-14 09:30:00 -04:00
Corey Farwell
5537955b17 Add doc example for OsString::reserve_exact. 2017-03-14 09:29:38 -04:00
Corey Farwell
4d57d92f07 Add doc example for OsString::reserve. 2017-03-14 09:29:09 -04:00
Corey Farwell
9a7b789c37 Add doc example for OsStr::to_os_string. 2017-03-14 09:28:30 -04:00
Alex Crichton
f4b4e097a6 Rollup merge of #40410 - clarcharr:os_string_shrink_to_fit, r=alexcrichton
OsString::shrink_to_fit.

Considering how the other capacity-related methods are there, I found it odd that this one wasn't included.

Will create a tracking issue once I get an OK on this.
2017-03-10 20:05:06 -08:00
Clar Charr
560944b982 Add From<Box<..>> implementations. 2017-03-10 14:57:57 -05:00
Clar Charr
83814fd8ab OsString::shrink_to_fit. 2017-03-10 12:15:30 -05:00
Tobias Bucher
da6e7c8f3a Distinguish the ways CStr::from_bytes_with_nul can fail 2017-03-09 13:31:55 +01:00
lukaramu
48331ef8a1 changed stability annotations
Changed stability annotations for the new Error and Display impls
for std::ffi::FromBytesWithNulError as they aren't subject to
stability the same way.
2017-02-21 16:39:32 +01:00
lukaramu
6a10e63ca0 added Error and Display impl for std::ffi::FromBytesWithNulError 2017-02-19 15:36:28 +01:00
Clar Charr
963843b1b3 Conversions between CStr/OsStr/Path and boxes. 2017-02-14 14:18:43 -05:00
Guillaume Gomez
27123d1a2a Add missing urls for OsStr and OsString 2017-01-22 11:40:49 +01:00
Corey Farwell
47143e3f07 Add doc examples for std::ffi::OsString fucntions/methods. 2017-01-21 10:19:55 -05:00
Corey Farwell
4794f95683 Expand {Path,OsStr}::{to_str,to_string_lossy} doc examples. 2017-01-05 09:52:14 -05:00
Oliver Middleton
18f5f9960f Slightly optimise CString
Avoid a reallocation in CString::from and CStr::to_owned.
2016-11-08 16:55:24 +00:00
bors
7a26aeca77 Auto merge of #36815 - alexcrichton:stabilize-1.13, r=aturon
std: Stabilize and deprecate APIs for 1.13

This commit is intended to be backported to the 1.13 branch, and works with the
following APIs:

Stabilized

* `i32::checked_abs`
* `i32::wrapping_abs`
* `i32::overflowing_abs`
* `RefCell::try_borrow`
* `RefCell::try_borrow_mut`

Deprecated

* `BinaryHeap::push_pop`
* `BinaryHeap::replace`
* `SipHash13`
* `SipHash24`
* `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map`
  module

Closes #28147
Closes #34767
Closes #35057
Closes #35070
2016-10-03 11:00:03 -07:00
Alex Crichton
10c3134da0 std: Stabilize and deprecate APIs for 1.13
This commit is intended to be backported to the 1.13 branch, and works with the
following APIs:

Stabilized

* `i32::checked_abs`
* `i32::wrapping_abs`
* `i32::overflowing_abs`
* `RefCell::try_borrow`
* `RefCell::try_borrow_mut`
* `DefaultHasher`
* `DefaultHasher::new`
* `DefaultHasher::default`

Deprecated

* `BinaryHeap::push_pop`
* `BinaryHeap::replace`
* `SipHash13`
* `SipHash24`
* `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map`
  module

Closes #28147
Closes #34767
Closes #35057
Closes #35070
2016-10-03 10:34:34 -07:00
Brian Anderson
0fb8379ed8 std: Remove plattform-specific code from os_str 2016-10-01 19:33:02 +00:00
Aleksey Kladov
300e13808e Remove CString drop test.
The test relies on the undefined behavior, and so may fail in some
circumstances. This can be worked around by stubbing a memory allocator
in the test, but it is a bit of work, and LLVM could still theoretically
eliminate the write of the zero byte in release mode (which is
intended).

So let's just remove the test and mark the function as inline. It
shouldn't be optimized away when inlined into the debug build of user's
code.
2016-09-26 20:50:32 +03:00