Skip to content

Commit bbc05ff

Browse files
authored
Merge pull request #3 from Trard/unhygienic
use unhygienic
2 parents 0b736fe + 49b0877 commit bbc05ff

File tree

4 files changed

+201
-80
lines changed

4 files changed

+201
-80
lines changed

Cargo.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Macro for common implementing methods in serde::Serializer trait"
44
categories = ["accessibility"]
55
keywords = ["serde", "macro", "serialize", "error"]
66

7-
version = "2.0.1"
7+
version = "3.0.0"
88
edition = "2021"
99

1010
repository = "https://github.com/Trard/impl_serialize"
@@ -16,6 +16,7 @@ license = "MIT OR Apache-2.0"
1616

1717
[dependencies]
1818
serde = "1.0"
19+
unhygienic2 = "0.1.0"
1920

2021
[dev-dependencies]
21-
thiserror = "1.0"
22+
thiserror = "1.0"

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This library provides a simple procedural macro for fast implementing serialize
44

55
```toml
66
[dependencies]
7-
impl_serialize = "2.0"
7+
impl_serialize = "3.0"
88
```
99

1010
# Example
@@ -45,25 +45,24 @@ impl ser::Serializer for MySerializer {
4545
type SerializeTupleStruct = ser::Impossible<Self::Ok, Self::Error>;
4646
type SerializeTupleVariant = ser::Impossible<Self::Ok, Self::Error>;
4747

48-
//with value type
48+
//value_type is metavariable (&str) what represents any serializing value type.
49+
//for example, value_type will be "i8" when seializing i8 or "bytes" when &[u8] (bytes);
50+
51+
//with value_type
4952
impl_serialize!(
50-
|value_type: &str| {
51-
Err(SerializationError::CannotSerializeFrom(value_type.to_string()))
52-
},
53+
Err(SerializationError::CannotSerializeFrom(value_type.to_string())),
5354
bool
5455
);
5556

56-
//without value type
57+
//without value_type
5758
impl_serialize!(
58-
|_| Err(SerializationError::OtherError),
59+
Err(SerializationError::OtherError),
5960
char
6061
);
6162

6263
//for many types
6364
impl_serialize!(
64-
|value_type: &str| {
65-
Err(SerializationError::CannotSerializeFrom(value_type.to_string()))
66-
},
65+
Err(SerializationError::CannotSerializeFrom(value_type.to_string())),
6766
[
6867
bytes,
6968
i8, i16, i32, i64,

0 commit comments

Comments
 (0)