This PR solves the issue identified at https://codeberg.org/JasterV/test-context/issues/2.
Previously, when defining the function argument that implements the `TestContext` trait, only "Ident" patterns were accepted (That is, only names).
So, the following was valid:
```rust
#[test]
fn my_test(context: MyContext) {}
```
But the following would throw an error:
```rust
#[test]
fn my_test(MyContext { n }: MyContext {}
```
With this PR, we are now able to accept any kind of "pattern" such as struct pattern matching, enum pattern matching... etc.
We only really care about the "type", and not the "pattern", so this PR makes sure that the "pattern" part of the binding is left untouched.
Tests have been added to ensure that destructuring a struct compiles
Co-authored-by: JasterV <49537445+JasterV@users.noreply.github.com>
Reviewed-on: https://codeberg.org/JasterV/test-context/pulls/4
This pull requests introduces changes that make the use of the `test_context` macro more flexible.
Now, if the teardown is not skipped (default behavior), either an `immutable` or a `mutable` reference can be used for the context.
If the teardown is skipped with the `skip_teardown` option, an `immutable`, a `mutable` reference or full ownership can be taken.
So now the following is possible:
```rust
#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown(_ctx: &mut TeardownPanicContext) {}
#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown_with_immutable_ref(_ctx: &TeardownPanicContext) {}
#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown_with_full_ownership(_ctx: TeardownPanicContext) {}
#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown(_ctx: &mut TeardownPanicContext) {}
#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown_with_immutable_ref(_ctx: &TeardownPanicContext) {}
#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown_with_full_ownership(_ctx: TeardownPanicContext) {}
```
* [FIX-CONFLICT-WITH-RSTEST-V2]: semi-stable version, fix test_context function, remove unnecessary field, remove wrapper function, add ability to work with rstest and same
* [FIX-CONFLICT-WITH-RSTEST-V2]: stable version, fix bugs with AssertUnwindSafe in sync_wrapper_body, remove redundant code, fix two tests, add notes for this tests
* [FIX-CONFLICT-WITH-RSTEST-V2]: stable version, fix context name extraction function, fix readme, fix docs, increase version of crate
---------
Co-authored-by: Vyacheslav Volkov <v.volkov@st-falcon.ru>