Files
bitcoin/src/util
MacroFake 006740b6f6 Merge bitcoin/bitcoin#25721: refactor: Replace BResult with util::Result
a23cca56c0 refactor: Replace BResult with util::Result (Ryan Ofsky)

Pull request description:

  Rename `BResult` class to `util::Result` and update the class interface to be more compatible with `std::optional` and with a full-featured result class implemented in https://github.com/bitcoin/bitcoin/pull/25665. Motivation for this change is to update existing `BResult` usages now so they don't have to change later when more features are added in https://github.com/bitcoin/bitcoin/pull/25665.

  This change makes the following improvements originally implemented in https://github.com/bitcoin/bitcoin/pull/25665:

  - More explicit API. Drops potentially misleading `BResult` constructor that treats any bilingual string argument as an error. Adds `util::Error` constructor so it is never ambiguous when a result is being assigned an error or non-error value.

  - Better type compatibility. Supports `util::Result<bilingual_str>` return values to hold translated messages which are not errors.

  - More standard and consistent API. `util::Result` supports most of the same operators and methods as `std::optional`. `BResult` had a less familiar interface with `HasRes`/`GetObj`/`ReleaseObj` methods. The Result/Res/Obj naming was also not internally consistent.

  - Better code organization. Puts `src/util/` code in the `util::` namespace so naming reflects code organization and it is obvious where the class is coming from. Drops "B" from name because it is undocumented what it stands for (bilingual?)

  - Has unit tests.

ACKs for top commit:
  MarcoFalke:
    ACK a23cca56c0 🏵
  jonatack:
    ACK a23cca56c0

Tree-SHA512: 2769791e08cd62f21d850aa13fa7afce4fb6875a9cedc39ad5025150dbc611c2ecfd7b3aba8b980a79fde7fbda13babdfa37340633c69b501b6e89727bad5b31
2022-08-05 15:33:45 +02:00
..
2021-12-30 19:36:57 +02:00
2022-07-08 11:06:01 +01:00
2022-06-23 14:35:04 +01:00
2020-12-31 09:45:41 +01:00
2020-12-31 09:45:41 +01:00
2021-05-11 10:38:18 +02:00
2022-07-20 15:34:36 +02:00
2022-02-21 14:32:53 +01:00
2021-12-30 19:36:57 +02:00
2022-07-20 10:34:46 +01:00
2022-07-20 10:34:46 +01:00
2022-05-05 20:50:24 +02:00
2022-04-05 13:30:06 +02:00
2022-07-20 10:34:46 +01:00
2022-07-26 11:04:14 +02:00
2021-03-04 18:24:00 +01:00
2021-12-30 19:36:57 +02:00
2022-07-08 11:06:01 +01:00