Skip to content

Commit

Permalink
More formatting of doc tests and example code
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 6, 2023
1 parent f82e955 commit 5eca644
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
19 changes: 9 additions & 10 deletions serde_test/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::fmt::Debug;
/// Runs both `assert_ser_tokens` and `assert_de_tokens`.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)]
Expand Down Expand Up @@ -43,7 +43,7 @@ where
/// Asserts that `value` serializes to the given `tokens`.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_ser_tokens, Token};
/// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)]
Expand Down Expand Up @@ -85,11 +85,10 @@ where
/// `error`.
///
/// ```edition2021
/// use std::sync::{Arc, Mutex};
/// use std::thread;
///
/// use serde_derive::Serialize;
/// use serde_test::{assert_ser_tokens_error, Token};
/// use std::sync::{Arc, Mutex};
/// use std::thread;
///
/// #[derive(Serialize)]
/// struct Example {
Expand All @@ -102,16 +101,16 @@ where
/// };
/// let lock = example.lock.clone();
///
/// let _ = thread::spawn(move || {
/// let thread = thread::spawn(move || {
/// // This thread will acquire the mutex first, unwrapping the result
/// // of `lock` because the lock has not been poisoned.
/// let _guard = lock.lock().unwrap();
///
/// // This panic while holding the lock (`_guard` is in scope) will
/// // poison the mutex.
/// panic!()
/// })
/// .join();
/// });
/// thread.join();
///
/// let expected = &[
/// Token::Struct {
Expand Down Expand Up @@ -143,7 +142,7 @@ where
/// Asserts that the given `tokens` deserialize into `value`.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_de_tokens, Token};
/// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)]
Expand Down Expand Up @@ -200,7 +199,7 @@ where
/// Asserts that the given `tokens` yield `error` when deserializing.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_de_tokens_error, Token};
/// #
/// #[derive(Serialize, Deserialize, PartialEq, Debug)]
Expand Down
18 changes: 9 additions & 9 deletions serde_test/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub enum Token {
/// A serialized unit struct of the given name.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand All @@ -198,7 +198,7 @@ pub enum Token {
/// A unit variant of an enum.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand Down Expand Up @@ -227,7 +227,7 @@ pub enum Token {
/// After this header is the value contained in the newtype struct.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand All @@ -248,7 +248,7 @@ pub enum Token {
/// After this header is the value contained in the newtype variant.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand Down Expand Up @@ -329,7 +329,7 @@ pub enum Token {
/// `TupleStructEnd`.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand Down Expand Up @@ -359,7 +359,7 @@ pub enum Token {
/// `TupleVariantEnd`.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand Down Expand Up @@ -428,7 +428,7 @@ pub enum Token {
/// After this header are the fields of the struct, followed by `StructEnd`.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand Down Expand Up @@ -463,7 +463,7 @@ pub enum Token {
/// `StructVariantEnd`.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand Down Expand Up @@ -500,7 +500,7 @@ pub enum Token {
/// The header to an enum of the given name.
///
/// ```edition2021
/// # use serde_derive::{Serialize, Deserialize};
/// # use serde_derive::{Deserialize, Serialize};
/// # use serde_test::{assert_tokens, Token};
/// #
/// # fn main() {
Expand Down

0 comments on commit 5eca644

Please sign in to comment.