summary refs log tree commit diff
path: root/src/libcore/convert.rs
AgeCommit message (Collapse)AuthorLines
2018-04-21Revert "Stabilize the TryFrom and TryInto traits"Felix S. Klock II-8/+4
This reverts commit e53a2a72743810e05f58c61c9d8a4c89b712ad2e.
2018-03-26Stabilize the TryFrom and TryInto traitsSimon Sapin-4/+8
Tracking issue: https://github.com/rust-lang/rust/issues/33417
2018-03-22Rollup merge of #49038 - canndrew:replace-infallible-with-never, r=SimonSapinkennytm-20/+1
replace `convert::Infallible` with `!`
2018-03-17update FIXME(#23442) to point to issue 45742 (Blanket impl of AsRef for Deref)Niv Kaminer-2/+2
2018-03-15replace `convert::Infallible` with `!`Andrew Cann-20/+1
2018-02-04Fix info about generic impls in AsMut docsMatt Brubeck-3/+3
This text was copy-pasted from the `AsRef` docs to `AsMut`, but needed some additional adjustments for correctness.
2017-09-23Simplify implementation of Display and Error for convert::Infallible.Jimmy Cuadra-2/+3
2017-09-21Impl fmt::Display for convert::Infallible.Jimmy Cuadra-0/+8
2017-09-18Derive additional traits for Infallible.Jimmy Cuadra-9/+1
2017-09-01Reword docs for Infallible to make them easier to understand.Jimmy Cuadra-6/+5
2017-08-29Add blanket TryFrom impl when From is implemented.Jimmy Cuadra-12/+29
Adds `impl<T, U> TryFrom<T> for U where U: From<T>`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417.
2017-06-15Update older URLs pointing to the first edition of the BookWonwoo Choi-2/+2
`compiler-plugins.html` is moved into the Unstable Book. Explanation is slightly modified to match the change.
2017-05-28Clarify docs on implementing Into.Clar Charr-1/+37
2017-05-02Address reviewest31-1/+1
2017-05-02Removal pass for anonymous parametersest31-1/+1
Removes occurences of anonymous parameters from the rustc codebase, as they are to be deprecated. See issue #41686 and RFC 1685.
2017-04-18Address review commentsDylan Maccora-24/+19
2017-04-08Removing broken examplesDylan Maccora-24/+3
2017-04-04AsMut exampleDylan Maccora-7/+15
2017-04-03Wrapped to 80 characters. Fix links.Dylan Maccora-40/+58
2017-04-01Convert docs clean up.Dylan Maccora-31/+114
2017-03-20Auto merge of #40281 - jimmycuadra:try-from-from-str, r=aturonbors-6/+18
Rename TryFrom's associated type and implement str::parse using TryFrom. Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err". See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968. `TryFrom<&str>` and `FromStr` are equivalent, so have the latter provide the former to ensure that. Using `TryFrom` in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to suggest implementing `TryFrom<&str>` instead for new code. See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994 and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827. Refs #33417.
2017-03-15Rename TryFrom's associated type and implement str::parse using TryFrom.Jimmy Cuadra-6/+18
Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err". See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968. TryFrom<&str> and FromStr are equivalent, so have the latter provide the former to ensure that. Using TryFrom in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to suggest implementing `TryFrom<&str>` instead for new code. See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994 and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827. Refs #33417.
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-4/+4
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-02-02Add a name for the parameter to `TryFrom::try_from`.Jimmy Cuadra-1/+1
Although signatures with anonymous parameters may not be deprecated or removed at this point, the team seems to agree that the ability to have an anonymous parameter is unfortunate historical baggage, and that we shouldn't create new code that uses it. Context: https://github.com/rust-lang/rust/issues/33417#issuecomment-276933861
2017-01-29Add missing url in convert moduleGuillaume Gomez-10/+18
2016-10-21Fix a few links in the docsOliver Middleton-3/+3
2016-09-15Add example in AsMut trait documentationMark-Simulacrum-0/+16
2016-08-31Add missing urls into convert moduleGuillaume Gomez-16/+39
2016-08-24Use `#[prelude_import]` in `libcore`.Jeffrey Seyfried-3/+0
2016-08-12fix small typos in std::convert documentationMatthew Piziak-4/+4
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-05-07Implement RFC 1542Steven Fackler-10/+47
cc #33417
2016-03-29verb agreement in core::convert docsAlex Burka-10/+10
2016-02-09Minor spelling fixesCarlos E. Garcia-1/+1
2016-01-31 Doc:std::convert: disambiguate traits and keywordsThomas Wickham-6/+6
2016-01-15Doc:std::convert: be more specific + typoThomas Wickham-21/+19
2016-01-14Doc:std::convert explicitely list generic implsThomas Wickham-0/+59
Also add a note about the necessary simplicity of the conversion. Related issue: #29349
2015-10-23Make `{Default, From, FromIterator, One, Zero}` well-formedAndrew Paseltiner-1/+1
Using these traits in an object context previously resulted in an RFC 1214 warning.
2015-06-17core: Split apart the global `core` featureAlex Crichton-4/+5
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-05-12TRPL: Borrow and AsRefSteve Klabnik-0/+5
These two traits are commonly confused. As such, explain the difference. Fixes #24163
2015-05-10Add #[inline] to AsRef<str>::as_ref for String and str.Jan Bujak-0/+1
2015-04-26Make From::from example more idiomatic / simplerCorey Farwell-3/+1
2015-04-24Remove reference to 'to'Steve Klabnik-1/+1
FIxes #24712
2015-04-10Add examples for ConvertSteve Klabnik-5/+51
2015-04-04s/Perform/Performs/Andrew Paseltiner-4/+4
Per [RFC #0505](https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#formatting).
2015-03-31Test fixes and rebase conflicts, round 2Alex Crichton-7/+0
2015-03-31rollup merge of #23879: seanmonstar/del-from-errorAlex Crichton-0/+7
Conflicts: src/libcore/error.rs
2015-03-31Stabilize `std::convert` and related codeAaron Turon-16/+22
* 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-30convert: remove FromError, use From<E> insteadSean McArthur-0/+7
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-26Revise use of conversion traitsAaron Turon-0/+16
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-23Add generic conversion traitsAaron Turon-0/+113
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]