From 56ab9b14fc642c67c61dcec0a9322a1feb57547b Mon Sep 17 00:00:00 2001 From: Devrandom Date: Tue, 16 Apr 2024 10:36:16 +0200 Subject: [PATCH] Fix std/no-std incompatibility --- examples/test.rs | 4 ++-- src/io/core.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/test.rs b/examples/test.rs index 698fe6114..18069c8c0 100644 --- a/examples/test.rs +++ b/examples/test.rs @@ -7,7 +7,7 @@ //! ``` -use serde_json::io::{Write, Result, Error}; +use serde_json::io::{Write, Result, Error, ErrorKind}; struct X { } @@ -18,7 +18,7 @@ impl Write for X { } fn flush(&mut self) -> Result<()> { - Err(Error {}) + Err(Error::new(ErrorKind::Other, "flush not implemented")) } } diff --git a/src/io/core.rs b/src/io/core.rs index b4a93f752..f1b132b57 100644 --- a/src/io/core.rs +++ b/src/io/core.rs @@ -23,7 +23,8 @@ impl Display for Error { } impl Error { - pub(crate) fn new(_kind: ErrorKind, _error: &'static str) -> Error { + /// see [`std::io::Error::new`] + pub fn new(_kind: ErrorKind, _error: &'static str) -> Error { Error } }