From 0951da52f9dc1628d5dd02c4ceb792a93ce56c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jagoda=20Estera=20=C5=9Al=C4=85zak?= <128227338+j-g00da@users.noreply.github.com> Date: Thu, 26 Jun 2025 04:36:12 +0200 Subject: [PATCH] docs(breaking-changes): improve migration guide for `Backend::Error` (#1908) Related: https://github.com/fujiapple852/trippy/pull/1588 --- BREAKING-CHANGES.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index 45146aaa..e5722cdc 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -193,6 +193,32 @@ and implement the `clear_region` method, which no longer has a default implement This change was made to provide greater flexibility for custom backends, particularly to remove the explicit dependency on `std::io` for backends that want to support `no_std` targets. +If your app or library uses the `Backend` trait directly - for example, by providing a generic +implementation for many backends - you may need to update the referenced error type. + +```diff +- fn run(mut terminal: Terminal) -> io::Result<()> { ++ fn run(mut terminal: Terminal) -> Result<(), B::Error> { +``` + +Alternatively, you can explicitly require the associated error to be `std::io::Error`. This approach +may require fewer changes in user code but is generally not recommended, as it limits compatibility +with third-party backends. Additionally, the error type used by built-in backends may or may not +change in the future, making this approach less future-proof compared to the previous one. + +```diff +- fn run(mut terminal: Terminal) -> io::Result<()> { ++ fn run>(mut terminal: Terminal) -> io::Result<()> { +``` + +If your application uses a concrete backend implementation, prefer specifying it explicitly +instead. + +```diff +- fn run(mut terminal: Terminal) -> io::Result<()> { ++ fn run(mut terminal: DefaultTerminal) -> io::Result<()> { +``` + ### The MSRV is now 1.85.0 ([#1860]) [#1860]: https://github.com/ratatui/ratatui/pull/1860