Skip to content

Commit

Permalink
docs: Add more examples on more bad inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alorel committed Sep 26, 2023
1 parent a7a3605 commit e784476
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Test__examples_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,27 @@ assert_eq!(format!("{:?}", Base(Wrapper("bar"))), "Wrapper(\"bar\")");

<details><summary><h3>Invalid inputs</h3></summary>

```rust
#[derive(DelegateDisplay, Debug)]
#[dboth(delegate_to(String))] // `delegate_to` is not supported on enums
enum SomeEnum {
Foo(Arc<String>)
}
```

```rust
#[derive(delegate_display::DelegateDisplay)]
#[ddisplay(base_bounds, bounds(T: Display))] // `base_bounds` and `bounds` are mutually exclusive
struct Generic<T>(T);
```

```rust
#[derive(delegate_display::DelegateDisplay)]
#[ddisplay(base_bounds)]
#[ddisplay(base_bounds)] // `dbodh` and `ddisplay` can be mixed, but the same option can't be used twice
struct Foo<T>(T);
```

```rust
#[derive(delegate_display::DelegateDebug)]
struct TooManyFields1 {
Expand All @@ -160,10 +181,7 @@ enum SomeEnum {

```rust
#[derive(delegate_display::DelegateDebug)]
#[ddebug(delegate_to(String))] // `delegate_to` is not supported on enums
enum SomeEnum {
Foo(std::sync::Arc<String>)
}
union Foo { bar: u8 } // Unions are not supported
```

</details>
Expand Down
1 change: 1 addition & 0 deletions examples/variations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ mod test {
#[test]
fn newtype() {
#[derive(DelegateDebug, DelegateDisplay)]
#[repr(transparent)]
struct Newtype(String);

const SRC: &'static str = "Lick the frog";
Expand Down
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@
//! ```
//!
//! ```compile_fail
//! #[derive(delegate_display::DelegateDisplay)]
//! #[ddisplay(base_bounds, bounds(T: Display))] // `base_bounds` and `bounds` are mutually exclusive
//! struct Generic<T>(T);
//! ```
//!
//! ```compile_fail
//! #[derive(delegate_display::DelegateDisplay)]
//! #[ddisplay(base_bounds)]
//! #[ddisplay(base_bounds)] // `dbodh` and `ddisplay` can be mixed, but the same option can't be used twice
//! struct Foo<T>(T);
//! ```
//!
//! ```compile_fail
//! #[derive(delegate_display::DelegateDebug)]
//! struct TooManyFields1 {
//! foo: u8,
Expand All @@ -177,6 +190,11 @@
//! }
//! ```
//!
//! ```compile_fail
//! #[derive(delegate_display::DelegateDebug)]
//! union Foo { bar: u8 } // Unions are not supported
//! ```
//!
//! </details>

#![deny(clippy::correctness, clippy::suspicious)]
Expand Down

0 comments on commit e784476

Please sign in to comment.