Skip to content

Commit

Permalink
Add test that serde_conv will not trigger clippy::ptr_arg
Browse files Browse the repository at this point in the history
Relates to #320 #729
  • Loading branch information
jonasbb committed Apr 17, 2024
1 parent 57e4ee2 commit 38e6375
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions serde_with_test/tests/serde_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,16 @@ fn string_to_u32(
#[derive(::s::Serialize, ::s::Deserialize)]
#[serde(crate = "::s")]
struct S2(#[serde(with = "number")] u32);

// Test for clippy warning clippy::ptr_arg
// warning: writing `&String` instead of `&str` involves a new object where a slice will do
// https://github.com/jonasbb/serde_with/pull/320
// https://github.com/jonasbb/serde_with/pull/729
serde_conv!(

Check failure on line 42 in serde_with_test/tests/serde_conv.rs

View workflow job for this annotation

GitHub Actions / clippy_check (ubuntu-latest, stable)

writing `&String` instead of `&str` involves a new object where a slice will do

Check failure on line 42 in serde_with_test/tests/serde_conv.rs

View workflow job for this annotation

GitHub Actions / clippy_check (ubuntu-latest, nightly)

writing `&String` instead of `&str` involves a new object where a slice will do

Check failure on line 42 in serde_with_test/tests/serde_conv.rs

View workflow job for this annotation

GitHub Actions / clippy_check (windows-latest, stable)

writing `&String` instead of `&str` involves a new object where a slice will do

Check failure on line 42 in serde_with_test/tests/serde_conv.rs

View workflow job for this annotation

GitHub Actions / clippy_check (windows-latest, nightly)

writing `&String` instead of `&str` involves a new object where a slice will do
pub StringAsHtml,
::std::string::String,
|string: &str| ::std::borrow::ToOwned::to_owned(string),
|string: ::std::string::String| -> ::std::result::Result<_, ::std::convert::Infallible> {
::std::result::Result::Ok(string)
}
);

0 comments on commit 38e6375

Please sign in to comment.