Skip to content

Commit 0e0ce5e

Browse files
committed
Make some macro styling more consistent
I have a better understanding of macro scoping now than when I wrote this. I tried to be (somewhat) pedantic about hygiene even though these macro definitions never leave their modules, which hurt readability.
1 parent 790b8d4 commit 0e0ce5e

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

src/transcode/stream.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,10 @@ impl<S: Serializer> Visitor<S> {
245245
}
246246
}
247247

248-
/// Implements [`de::Visitor`] methods that simply forward scalar values to the appropriate
249-
/// [`Serializer`] method.
250-
macro_rules! xt_transcode_impl_scalar_visitors {
251-
($($name:ident($($arg:ident: $ty:ty)?) => $op:expr;)*) => {
252-
$(fn $name<E: ::serde::de::Error>(self, $($arg: $ty)?) -> ::std::result::Result<Self::Value, E> {
248+
/// Implements the simplest [`de::Visitor`] methods that forward scalars to a [`Serializer`].
249+
macro_rules! impl_forward_scalar_visitors {
250+
( $( $name:ident($($arg:ident: $ty:ty)?) => $op:expr; )* ) => {
251+
$(fn $name<E: de::Error>(self, $($arg: $ty)?) -> Result<Self::Value, E> {
253252
self.forward_scalar($op)
254253
})*
255254
};
@@ -277,7 +276,7 @@ impl<'de, S: Serializer> de::Visitor<'de> for &mut Visitor<S> {
277276
f.write_str("any supported value")
278277
}
279278

280-
xt_transcode_impl_scalar_visitors! {
279+
impl_forward_scalar_visitors! {
281280
visit_unit() => |ser| ser.serialize_unit();
282281

283282
visit_bool(v: bool) => |ser| ser.serialize_bool(v);

src/transcode/value.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ impl Serialize for Value<'_> {
7272
}
7373
}
7474

75-
/// Implements [`de::Visitor`] methods that simply shove values into [`Value`]s.
76-
macro_rules! xt_transcode_impl_value_visitors {
77-
($($name:ident($($arg:ident: $ty:ty)?) => $result:expr;)*) => {
75+
/// Implements the simplest [`de::Visitor`] methods that shove scalars into [`Value`]s.
76+
macro_rules! impl_value_scalar_visitors {
77+
( $( $name:ident($($arg:ident: $ty:ty)?) => $result:expr; )* ) => {
7878
$(fn $name<E: de::Error>(self, $($arg: $ty)?) -> Result<Self::Value, E> {
7979
Ok($result)
8080
})*
@@ -95,7 +95,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for Value<'a> {
9595
f.write_str("any supported value")
9696
}
9797

98-
xt_transcode_impl_value_visitors! {
98+
impl_value_scalar_visitors! {
9999
visit_unit() => Value::Unit;
100100

101101
visit_bool(v: bool) => Value::Bool(v);

0 commit comments

Comments
 (0)