Skip to content

Commit

Permalink
refactor: Use core::error
Browse files Browse the repository at this point in the history
  • Loading branch information
GrayJack committed Dec 5, 2024
1 parent b8b4468 commit 338c14d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ All notable changes to the library should be put here
- Refactor: Use default implementation on `JanetArgs` trait for most methods
- Refactor: Simplify `jpanic!` macro
- Refactor: janetrs_macros 0.7.0 — Update `syn` crate to 2.0
- Refactor: Use `core::error`
- Fix: janetrs_macros 0.7.1 — Fix `janet_fn` attribute macro not generating Janet docstring correctly
- Fix: janetrs_version — Add missed feature flag `inline-more`
- Fix: Fix conversion from `Janet` to 32 bit integers
Expand Down
3 changes: 2 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! This module implements anything required to run a Janet client.
use core::{
error::Error as StdError,
fmt::{self, Display},
sync::atomic::{AtomicBool, Ordering},
};

#[cfg(feature = "std")]
use std::{error::Error as StdError, thread_local};
use std::thread_local;

use crate::{
Janet, JanetTable,
Expand Down
8 changes: 1 addition & 7 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! - `'data` is the lifetime of data that is owned by the Janet GC.
use core::{
cmp::Ordering,
error,
ffi::{CStr, c_char},
fmt::{self, Display, Write},
num::ParseIntError,
Expand All @@ -18,9 +19,6 @@ use alloc::{
vec::Vec,
};

#[cfg(feature = "std")]
use std::error;

use evil_janet::{
JANET_INTMAX_DOUBLE, JANET_INTMIN_DOUBLE, Janet as CJanet, JanetType as CJanetType,
};
Expand Down Expand Up @@ -124,8 +122,6 @@ impl From<ParseIntError> for JanetConversionError {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl error::Error for JanetConversionError {}

impl Display for JanetConversionError {
Expand Down Expand Up @@ -792,8 +788,6 @@ impl Display for Janet {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl error::Error for Janet {}

impl PartialEq<&Self> for Janet {
Expand Down
4 changes: 1 addition & 3 deletions src/types/abstract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ impl fmt::Display for AbstractError {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for AbstractError {}
impl core::error::Error for AbstractError {}

/// Type that represents the Janet Abstract type.
///
Expand Down
8 changes: 2 additions & 6 deletions src/types/function.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Janet function types.
use core::{
error,
fmt::{self, Display},
marker::PhantomData,
ptr,
Expand All @@ -9,10 +10,7 @@ use core::{
use core::fmt::Write;

#[cfg(feature = "std")]
use std::{
error,
io::{self, Write},
};
use std::io::{self, Write};

use evil_janet::{JanetFunction as CJanetFunction, janet_pcall};

Expand Down Expand Up @@ -157,8 +155,6 @@ impl Display for CallError<'_> {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl error::Error for CallError<'_> {}

/// A representation of a Janet function defined at the Janet side.
Expand Down
4 changes: 1 addition & 3 deletions src/types/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1896,9 +1896,7 @@ impl fmt::Display for OccupiedError<'_, '_> {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for OccupiedError<'_, '_> {}
impl core::error::Error for OccupiedError<'_, '_> {}

/// An iterator over a reference to the [`JanetTable`] key-value pairs.
#[derive(Clone)]
Expand Down

0 comments on commit 338c14d

Please sign in to comment.