Commit Graph

24 Commits

Author SHA1 Message Date
Mark-Simulacrum
102ee5e70a Add example in AsMut trait documentation 2016-09-15 19:47:04 -06:00
Guillaume Gomez
b712f74508 Add missing urls into convert module 2016-08-31 16:15:19 +02:00
Jeffrey Seyfried
e2ad3be178 Use #[prelude_import] in libcore. 2016-08-24 22:12:23 +00:00
Matthew Piziak
bfca761c8c fix small typos in std::convert documentation
Fix subject-verb agreement in copypasta: "`AsRef` dereference" to
"`AsRef` dereferences".

Formalize "eg" to "e.g." Italicization of common Latin abbreviations
seems to be going out of style in written English, so I left it plain.
2016-08-12 12:20:56 -04:00
Steven Fackler
a9779df188 Implement RFC 1542
cc #33417
2016-05-07 08:52:41 -07:00
Alex Burka
0af3e70842 verb agreement in core::convert docs 2016-03-29 12:23:09 -04:00
Carlos E. Garcia
02aa0aff2f Minor spelling fixes 2016-02-09 11:52:39 -05:00
Thomas Wickham
a0cd46554d Doc:std::convert: disambiguate traits and keywords 2016-01-31 12:26:15 +01:00
Thomas Wickham
6cda8e4eaa Doc:std::convert: be more specific + typo 2016-01-15 01:24:33 +01:00
Thomas Wickham
58d2c7909f Doc:std::convert explicitely list generic impls
Also add a note about the necessary simplicity of the conversion.
Related issue: #29349
2016-01-14 16:06:53 +01:00
Andrew Paseltiner
863bb1f515 Make {Default, From, FromIterator, One, Zero} well-formed
Using these traits in an object context previously resulted in an RFC
1214 warning.
2015-10-23 21:56:23 -04:00
Alex Crichton
c14d86fd3f core: Split apart the global core feature
This commit shards the broad `core` feature of the libcore library into finer
grained features. This split groups together similar APIs and enables tracking
each API separately, giving a better sense of where each feature is within the
stabilization process.

A few minor APIs were deprecated along the way:

* Iterator::reverse_in_place
* marker::NoCopy
2015-06-17 09:06:59 -07:00
Steve Klabnik
e780fb270c TRPL: Borrow and AsRef
These two traits are commonly confused. As such, explain the difference.

Fixes #24163
2015-05-12 10:53:50 -04:00
Jan Bujak
a168dbad15 Add #[inline] to AsRef<str>::as_ref for String and str. 2015-05-10 14:06:41 +02:00
Corey Farwell
57284e6880 Make From::from example more idiomatic / simpler 2015-04-26 23:18:19 -04:00
Steve Klabnik
15c3435b87 Remove reference to 'to'
FIxes #24712
2015-04-24 11:02:07 -04:00
Steve Klabnik
288b1c9aba Add examples for Convert 2015-04-10 12:44:20 -04:00
Andrew Paseltiner
2d198955d3 s/Perform/Performs/
Per [RFC #0505](https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#formatting).
2015-04-04 10:26:14 -04:00
Alex Crichton
30532884f8 Test fixes and rebase conflicts, round 2 2015-03-31 15:56:33 -07:00
Alex Crichton
e10ee2c857 rollup merge of #23879: seanmonstar/del-from-error
Conflicts:
	src/libcore/error.rs
2015-03-31 15:53:39 -07:00
Aaron Turon
9fc51efe33 Stabilize std::convert and related code
* Marks `#[stable]` the contents of the `std::convert` module.

* Added methods `PathBuf::as_path`, `OsString::as_os_str`,
  `String::as_str`, `Vec::{as_slice, as_mut_slice}`.

* Deprecates `OsStr::from_str` in favor of a new, stable, and more
  general `OsStr::new`.

* Adds unstable methods `OsString::from_bytes` and `OsStr::{to_bytes,
  to_cstring}` for ergonomic FFI usage.

[breaking-change]
2015-03-31 11:24:38 -07:00
Sean McArthur
e17f4fc1d4 convert: remove FromError, use From<E> instead
This removes the FromError trait, since it can now be expressed using
the new convert::Into trait. All implementations of FromError<E> where
changed to From<E>, and `try!` was changed to use From::from instead.

Because this removes FromError, it is a breaking change, but fixing it
simply requires changing the words `FromError` to `From`, and
`from_error` to `from`.

[breaking-change]
2015-03-30 18:08:58 -07:00
Aaron Turon
e7525cf620 Revise use of conversion traits
This commit revises `path` and `os_str` to use blanket impls for `From`
on reference types. This both cuts down on the number of required impls,
and means that you can pass through e.g. `T: AsRef<OsStr>` to
`PathBuf::from` without an intermediate call to `as_ref`.

It also makes a FIXME note for later generalizing the blanket impls for
`AsRef` and `AsMut` to use `Deref`/`DerefMut`, once it is possible to do
so.
2015-03-26 13:54:48 -07:00
Aaron Turon
8389253df0 Add generic conversion traits
This commit:

* Introduces `std::convert`, providing an implementation of
RFC 529.

* Deprecates the `AsPath`, `AsOsStr`, and `IntoBytes` traits, all
in favor of the corresponding generic conversion traits.

  Consequently, various IO APIs now take `AsRef<Path>` rather than
`AsPath`, and so on. Since the types provided by `std` implement both
traits, this should cause relatively little breakage.

* Deprecates many `from_foo` constructors in favor of `from`.

* Changes `PathBuf::new` to take no argument (creating an empty buffer,
  as per convention). The previous behavior is now available as
  `PathBuf::from`.

* De-stabilizes `IntoCow`. It's not clear whether we need this separate trait.

Closes #22751
Closes #14433

[breaking-change]
2015-03-23 15:01:45 -07:00