io: fix doc for write_i8 to use signed integers (#5040)

Fixes: #5039
This commit is contained in:
grydholt
2022-09-27 22:08:20 +00:00
committed by GitHub
parent 909de08845
commit aedcec666d
+5 -5
View File
@@ -406,7 +406,7 @@ cfg_io_util! {
/// ``` /// ```
fn write_u8(&mut self, n: u8) -> WriteU8; fn write_u8(&mut self, n: u8) -> WriteU8;
/// Writes an unsigned 8-bit integer to the underlying writer. /// Writes a signed 8-bit integer to the underlying writer.
/// ///
/// Equivalent to: /// Equivalent to:
/// ///
@@ -425,7 +425,7 @@ cfg_io_util! {
/// ///
/// # Examples /// # Examples
/// ///
/// Write unsigned 8 bit integers to a `AsyncWrite`: /// Write signed 8 bit integers to a `AsyncWrite`:
/// ///
/// ```rust /// ```rust
/// use tokio::io::{self, AsyncWriteExt}; /// use tokio::io::{self, AsyncWriteExt};
@@ -434,10 +434,10 @@ cfg_io_util! {
/// async fn main() -> io::Result<()> { /// async fn main() -> io::Result<()> {
/// let mut writer = Vec::new(); /// let mut writer = Vec::new();
/// ///
/// writer.write_u8(2).await?; /// writer.write_i8(-2).await?;
/// writer.write_u8(5).await?; /// writer.write_i8(126).await?;
/// ///
/// assert_eq!(writer, b"\x02\x05"); /// assert_eq!(writer, b"\xFE\x7E");
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```