Skip to content

Commit c7609f0

Browse files
committed
docs
1 parent 789e52e commit c7609f0

3 files changed

Lines changed: 73 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "flexpect"
33
version = "0.1.0"
44
edition = "2018"
55
license = "MIT OR Apache-2.0"
6-
description = "`#[flexpect::e(...)]` compiles to `#[expect(...)]` for newer versions of Rust and to `#[allow(...)]` when not supported."
6+
description = "#[flexpect::e(...)] compiles to #[expect(...)] for newer versions of Rust and to #[allow(...)] when not supported."
77
readme = "README.md"
88
repository = "https://github.com/rusticstuff/flexpect"
99
homepage = "https://github.com/rusticstuff/flexpect"

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ flexpect = "0.1.0"
1717
Then use the `#[flexpect::e(...)]` or `#[flexpect::flexpect(...)]` attributes instead of `#[expect(...)]`:
1818

1919
```rust
20-
#[flexpect::e(unused_variables)] // instead of #[expect(unused_variables)]
20+
// instead of #[expect(unused_variables)]
21+
#[flexpect::e(unused_variables)]
2122
fn example() {
2223
let x = 1;
2324
}
@@ -26,7 +27,8 @@ fn example() {
2627
```rust
2728
use flexpect::flexpect;
2829

29-
#[flexpect(clippy::clone_on_copy)] // instead of #[expect(clippy::clone_on_copy)]
30+
// instead of #[expect(clippy::clone_on_copy)]
31+
#[flexpect(clippy::clone_on_copy)]
3032
fn clippy_example() {
3133
let _ = 32.clone();
3234
}

src/lib.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,38 +48,106 @@ extern crate proc_macro;
4848

4949
use proc_macro::TokenStream;
5050

51+
/// `#[flexpect::e(...)]` compiles to `#[expect(...)]` for newer versions of Rust and to `#[allow(...)]` when not supported.
52+
///
53+
/// # Example
54+
///
55+
/// ```
56+
/// #[flexpect::e(clippy::clone_on_copy)]
57+
/// fn clippy_example() {
58+
/// let _ = 32.clone();
59+
/// }
60+
/// ```
5161
#[rustversion::any(before(1.43.0))]
5262
#[proc_macro_attribute]
5363
pub fn e(_attr_args: TokenStream, item: TokenStream) -> TokenStream {
5464
// using #[allow(...)] does not work before 1.43.0 due to a bug
5565
item
5666
}
5767

68+
/// `#[flexpect::e(...)]` compiles to `#[expect(...)]` for newer versions of Rust and to `#[allow(...)]` when not supported.
69+
///
70+
/// # Example
71+
///
72+
/// ```
73+
/// #[flexpect::e(clippy::clone_on_copy)]
74+
/// fn clippy_example() {
75+
/// let _ = 32.clone();
76+
/// }
77+
/// ```
5878
#[rustversion::all(since(1.43.0), before(1.81))]
5979
#[proc_macro_attribute]
6080
pub fn e(attr_args: TokenStream, item: TokenStream) -> TokenStream {
6181
create_attr("allow", attr_args, item)
6282
}
6383

84+
/// `#[flexpect::e(...)]` compiles to `#[expect(...)]` for newer versions of Rust and to `#[allow(...)]` when not supported.
85+
///
86+
/// # Example
87+
///
88+
/// ```
89+
/// #[flexpect::e(clippy::clone_on_copy)]
90+
/// fn clippy_example() {
91+
/// let _ = 32.clone();
92+
/// }
93+
/// ```
6494
#[rustversion::since(1.81)]
6595
#[proc_macro_attribute]
6696
pub fn e(attr_args: TokenStream, item: TokenStream) -> TokenStream {
6797
create_attr("expect", attr_args, item)
6898
}
6999

100+
/// `#[flexpect(...)]` compiles to `#[expect(...)]` for newer versions of Rust and to `#[allow(...)]` when not supported.
101+
///
102+
/// # Example
103+
///
104+
/// ```
105+
/// use flexpect::flexpect;
106+
///
107+
/// #[flexpect(clippy::clone_on_copy)] // instead of #[expect(clippy::clone_on_copy)]
108+
/// fn clippy_example() {
109+
/// let _ = 32.clone();
110+
/// }
111+
/// ```
70112
#[rustversion::any(before(1.43.0))]
71113
#[proc_macro_attribute]
72114
pub fn flexpect(_attr_args: TokenStream, item: TokenStream) -> TokenStream {
73115
// using #[allow(...)] does not work before 1.43.0 due to a bug
74116
item
75117
}
76118

119+
/// `#[flexpect(...)]` compiles to `#[expect(...)]` for newer versions of Rust and to `#[allow(...)]` when not supported.
120+
///
121+
/// # Example
122+
///
123+
/// ```
124+
/// use flexpect::flexpect;
125+
///
126+
/// // instead of #[expect(clippy::clone_on_copy)]
127+
/// #[flexpect(clippy::clone_on_copy)]
128+
/// fn clippy_example() {
129+
/// let _ = 32.clone();
130+
/// }
131+
/// ```
77132
#[rustversion::all(since(1.43.0), before(1.81))]
78133
#[proc_macro_attribute]
79134
pub fn flexpect(attr_args: TokenStream, item: TokenStream) -> TokenStream {
80135
create_attr("allow", attr_args, item)
81136
}
82137

138+
/// `#[flexpect(...)]` compiles to `#[expect(...)]` for newer versions of Rust and to `#[allow(...)]` when not supported.
139+
///
140+
/// # Example
141+
///
142+
/// ```
143+
/// use flexpect::flexpect;
144+
///
145+
/// // instead of #[expect(clippy::clone_on_copy)]
146+
/// #[flexpect(clippy::clone_on_copy)]
147+
/// fn clippy_example() {
148+
/// let _ = 32.clone();
149+
/// }
150+
/// ```
83151
#[rustversion::since(1.81)]
84152
#[proc_macro_attribute]
85153
pub fn flexpect(attr_args: TokenStream, item: TokenStream) -> TokenStream {

0 commit comments

Comments
 (0)