From 4cf30c0022a434718799b66cdf8911ad8030d0e1 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Fri, 7 Oct 2022 15:42:05 +0300 Subject: [PATCH 1/2] Improved documentation for `std::io::Error` --- library/std/src/io/error.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index feb3fb989a7..2bbfbe38a24 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -481,6 +481,7 @@ impl Error { /// originate from the OS itself. The `error` argument is an arbitrary /// payload which will be contained in this [`Error`]. /// + /// Note that this function allocates memory on the heap. /// If no extra payload is required, use the `From` conversion from /// `ErrorKind`. /// @@ -495,7 +496,7 @@ impl Error { /// // errors can also be created from other errors /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); /// - /// // creating an error without payload + /// // creating an error without payload (also without memory allocation) /// let eof_error = Error::from(ErrorKind::UnexpectedEof); /// ``` #[stable(feature = "rust1", since = "1.0.0")] From f95e8532222479c417fdf9fffc6ce1ab8cda3413 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 14 Oct 2022 12:17:07 +0100 Subject: [PATCH 2/2] Tweak grammar --- library/std/src/io/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 2bbfbe38a24..837145bfaed 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -496,7 +496,7 @@ impl Error { /// // errors can also be created from other errors /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); /// - /// // creating an error without payload (also without memory allocation) + /// // creating an error without payload (and without memory allocation) /// let eof_error = Error::from(ErrorKind::UnexpectedEof); /// ``` #[stable(feature = "rust1", since = "1.0.0")]