summaryrefslogtreecommitdiffstats
path: root/library/core/src/str
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--library/core/src/str/error.rs3
-rw-r--r--library/core/src/str/mod.rs1
-rw-r--r--library/core/src/str/pattern.rs2
-rw-r--r--library/core/src/str/traits.rs18
4 files changed, 12 insertions, 12 deletions
diff --git a/library/core/src/str/error.rs b/library/core/src/str/error.rs
index 343889b69..a11b5add4 100644
--- a/library/core/src/str/error.rs
+++ b/library/core/src/str/error.rs
@@ -1,6 +1,5 @@
//! Defines utf8 error type.
-#[cfg(not(bootstrap))]
use crate::error::Error;
use crate::fmt;
@@ -124,7 +123,6 @@ impl fmt::Display for Utf8Error {
}
}
-#[cfg(not(bootstrap))]
#[stable(feature = "rust1", since = "1.0.0")]
impl Error for Utf8Error {
#[allow(deprecated)]
@@ -148,7 +146,6 @@ impl fmt::Display for ParseBoolError {
}
}
-#[cfg(not(bootstrap))]
#[stable(feature = "rust1", since = "1.0.0")]
impl Error for ParseBoolError {
#[allow(deprecated)]
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index f673aa2a4..fbc0fc397 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -2642,5 +2642,4 @@ impl_fn_for_zst! {
}
#[stable(feature = "rust1", since = "1.0.0")]
-#[cfg(not(bootstrap))]
impl !crate::error::Error for &str {}
diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs
index 031fb8e8b..ec2cb429e 100644
--- a/library/core/src/str/pattern.rs
+++ b/library/core/src/str/pattern.rs
@@ -267,7 +267,7 @@ pub unsafe trait Searcher<'a> {
/// The index ranges returned by this trait are not required
/// to exactly match those of the forward search in reverse.
///
-/// For the reason why this trait is marked unsafe, see them
+/// For the reason why this trait is marked unsafe, see the
/// parent trait [`Searcher`].
pub unsafe trait ReverseSearcher<'a>: Searcher<'a> {
/// Performs the next search step starting from the back.
diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs
index e9649fc91..d3ed811b1 100644
--- a/library/core/src/str/traits.rs
+++ b/library/core/src/str/traits.rs
@@ -507,7 +507,6 @@ unsafe impl const SliceIndex<str> for ops::RangeToInclusive<usize> {
///
/// ```
/// use std::str::FromStr;
-/// use std::num::ParseIntError;
///
/// #[derive(Debug, PartialEq)]
/// struct Point {
@@ -515,18 +514,21 @@ unsafe impl const SliceIndex<str> for ops::RangeToInclusive<usize> {
/// y: i32
/// }
///
+/// #[derive(Debug, PartialEq, Eq)]
+/// struct ParsePointError;
+///
/// impl FromStr for Point {
-/// type Err = ParseIntError;
+/// type Err = ParsePointError;
///
/// fn from_str(s: &str) -> Result<Self, Self::Err> {
/// let (x, y) = s
/// .strip_prefix('(')
/// .and_then(|s| s.strip_suffix(')'))
/// .and_then(|s| s.split_once(','))
-/// .unwrap();
+/// .ok_or(ParsePointError)?;
///
-/// let x_fromstr = x.parse::<i32>()?;
-/// let y_fromstr = y.parse::<i32>()?;
+/// let x_fromstr = x.parse::<i32>().map_err(|_| ParsePointError)?;
+/// let y_fromstr = y.parse::<i32>().map_err(|_| ParsePointError)?;
///
/// Ok(Point { x: x_fromstr, y: y_fromstr })
/// }
@@ -538,6 +540,8 @@ unsafe impl const SliceIndex<str> for ops::RangeToInclusive<usize> {
/// // Implicit calls, through parse
/// assert_eq!("(1,2)".parse(), expected);
/// assert_eq!("(1,2)".parse::<Point>(), expected);
+/// // Invalid input string
+/// assert!(Point::from_str("(1 2)").is_err());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait FromStr: Sized {
@@ -573,8 +577,8 @@ impl FromStr for bool {
/// Parse a `bool` from a string.
///
- /// Yields a `Result<bool, ParseBoolError>`, because `s` may or may not
- /// actually be parseable.
+ /// The only accepted values are `"true"` and `"false"`. Any other input
+ /// will return an error.
///
/// # Examples
///