-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
serde_attr
example and update README.md
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))] | ||
#![allow(unused)] | ||
|
||
use std::sync::Mutex; | ||
|
||
// Traits `serde::Serialize` and `serde::Deserialize` cannot be derived for `Context` because it | ||
// contains a `Mutex`. | ||
#[derive(Default)] | ||
struct Context { | ||
lock: Mutex<()>, | ||
} | ||
|
||
impl Clone for Context { | ||
fn clone(&self) -> Self { | ||
Self { | ||
lock: Mutex::new(()), | ||
} | ||
} | ||
} | ||
|
||
#[test_fuzz::test_fuzz] | ||
fn target(#[serde(skip)] context: Context, x: i32) { | ||
assert!(x >= 0); | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
target(Context::default(), 0); | ||
} |