Skip to content

Commit

Permalink
Sync up changelog and upgrading guide
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Nov 23, 2021
1 parent 86fabf9 commit 321d6a4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

See the [upgrading guide][] for more detailed information about
modifying code to account for new releases.

[upgrading guide]: https://docs.rs/snafu/*/snafu/guide/upgrading/index.html

## [0.7.0] - XXXX-XX-XX

### Added
Expand Down
60 changes: 54 additions & 6 deletions src/guide/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

## Version 0.6 → 0.7

Upgrading should be a tedious but straightforward process. To assist
upgrading your code, you can use the [snafu-upgrade-assistant], which
attempts to automatically update breaking changes.

[snafu-upgrade-assistant]: https://github.com/shepmaster/snafu-upgrade-assistant

### Context selector names have changed

Previously, context selector names for enum errors exactly matched
Expand All @@ -17,13 +23,55 @@ confusion for people new to SNAFU. It was also inconsistent with
context selector names for struct errors.

Now, context selectors for both enum and struct errors use the `Snafu`
suffix.
suffix. Any existing `Error` suffix is removed before `Snafu` is
added.

Upgrading should be a tedious but straightforward process. To assist
upgrading your code, you can use the [snafu-upgrade-assistant], which
attempts to locate all of your context selectors and rename them.
#### Before

[snafu-upgrade-assistant]: https://github.com/shepmaster/snafu-upgrade-assistant
```rust,ignore
#[derive(Debug, Snafu)]
struct StructError;
#[derive(Debug, Snafu)]
enum EnumError {
VariantError,
}
ensure!(false, StructContext);
ensure!(false, VariantError);
```

#### After

```rust,ignore
#[derive(Debug, Snafu)]
struct StructError;
#[derive(Debug, Snafu)]
enum EnumError {
VariantError,
}
ensure!(false, StructSnafu);
ensure!(false, VariantSnafu);
```

### `with_context` takes an argument

`ResultExt::with_context`, `TryFutureExt::with_context`, and
`TryStreamExt::with_context` now pass the error into the closure.

#### Before

```rust,ignore
some_result.with_context(|| ContextSelector);
```

#### After

```rust,ignore
some_result.with_context(|_| ContextSelector);
```

### String attribute parsing is no longer supported

Expand Down Expand Up @@ -75,7 +123,7 @@ The `backtrace-crate` feature flag has been renamed to
`backtraces-impl-backtrace-crate`. The backtrace returned by
`ErrorCompat::backtrace` is now the `backtrace::Backtrace` type when
this flag is enabled, so the implementation of `AsRef` has been
removed..
removed.

### Futures

Expand Down

0 comments on commit 321d6a4

Please sign in to comment.