Skip to content

Commit

Permalink
Fix std/no-std incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
devrandom committed Apr 16, 2024
1 parent 1066cca commit 09e313d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/test.rs
Expand Up @@ -7,7 +7,7 @@
//! ```


use serde_json::io::{Write, Result, Error};
use serde_json::io::{Write, Result, Error, ErrorKind};

struct X {
}
Expand All @@ -18,7 +18,7 @@ impl Write for X {
}

fn flush(&mut self) -> Result<()> {
Err(Error {})
Err(Error::new(ErrorKind::Other, "flush not implemented"))
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/io/core.rs
Expand Up @@ -14,7 +14,9 @@ pub enum ErrorKind {
/// see [`std::io::Error`]
// I/O errors can never occur in no-std mode. All our no-std I/O implementations
// are infallible.
pub struct Error;
pub struct Error {
_priv: (),
}

impl Display for Error {
fn fmt(&self, _formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -23,8 +25,9 @@ impl Display for Error {
}

impl Error {
pub(crate) fn new(_kind: ErrorKind, _error: &'static str) -> Error {
Error
/// see [`std::io::Error::new`]
pub fn new(_kind: ErrorKind, _error: &'static str) -> Error {
Error(())
}
}

Expand Down

0 comments on commit 09e313d

Please sign in to comment.