Skip to content

Commit 3ad6e2b

Browse files
authored
Merge pull request #7 from chanced/impl-std-error
adds missing `impl std::error::Error`s to `Error`, `NotFoundError`, `MalformedError`
2 parents b7e2976 + c7fbd7e commit 3ad6e2b

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

Cargo.toml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
[package]
2-
name = "jsonptr"
3-
version = "0.3.4"
4-
edition = "2021"
5-
description = "Data structures and logic for resolving, assigning, and deleting by JSON Pointers (RFC 6901)"
2+
authors = ["chance dinkins"]
3+
description = "Data structures and logic for resolving, assigning, and deleting by JSON Pointers (RFC 6901)"
64
documentation = "https://docs.rs/jsonptr"
7-
keywords = ["json-pointer", "rfc-6901", "6901"]
8-
license = "MIT OR Apache-2.0"
9-
repository = "https://github.com/chanced/jsonptr"
10-
homepage = "https://github.com/chanced/jsonptr"
11-
authors = ["chance dinkins"]
12-
5+
edition = "2021"
6+
homepage = "https://github.com/chanced/jsonptr"
7+
keywords = ["json-pointer", "rfc-6901", "6901"]
8+
license = "MIT OR Apache-2.0"
9+
name = "jsonptr"
10+
repository = "https://github.com/chanced/jsonptr"
11+
version = "0.3.4"
1312

1413
[dependencies]
15-
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
16-
serde = { version = "1.0", default-features = false, features = ["alloc"] }
17-
url = { version = "2", optional = true }
18-
uniresid = { version = "0.1.4", optional = true }
1914
fluent-uri = { version = "0.1.4", optional = true, default-features = false }
15+
serde = { version = "1.0", default-features = false, features = ["alloc"] }
16+
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
17+
uniresid = { version = "0.1.4", optional = true }
18+
url = { version = "2", optional = true }
2019

2120
[features]
2221
default = []
23-
std = ["serde/std", "serde_json/std", "fluent-uri?/std"]
22+
std = ["serde/std", "serde_json/std", "fluent-uri?/std"]

src/error.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ impl Display for Error {
8585
}
8686
}
8787

88+
#[cfg(feature = "std")]
89+
impl std::error::Error for Error {}
90+
8891
/// Represents an error that occurs when attempting to resolve a `Pointer` that
8992
/// encounters a leaf node (i.e. a scalar / null value) which is not the root
9093
/// of the `Pointer`.
@@ -106,6 +109,10 @@ pub struct UnresolvableError {
106109
/// `Object` or an `Array`.
107110
pub leaf: Option<Token>,
108111
}
112+
113+
#[cfg(feature = "std")]
114+
impl std::error::Error for UnresolvableError {}
115+
109116
impl UnresolvableError {
110117
/// Creates a new `UnresolvableError` with the given `Pointer`.
111118
pub fn new(pointer: Pointer) -> Self {
@@ -298,6 +305,8 @@ impl Display for NotFoundError {
298305
)
299306
}
300307
}
308+
#[cfg(feature = "std")]
309+
impl std::error::Error for NotFoundError {}
301310

302311
/// Returned from `Pointer::replace_token` when the provided index is out of
303312
/// bounds.
@@ -312,6 +321,7 @@ pub struct ReplaceTokenError {
312321
}
313322
#[cfg(feature = "std")]
314323
impl std::error::Error for ReplaceTokenError {}
324+
315325
impl Display for ReplaceTokenError {
316326
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
317327
write!(

0 commit comments

Comments
 (0)