Page MenuHomePhabricator

[services] Backup - use `anyhow::Result` short form
ClosedPublic

Authored by bartek on Oct 5 2022, 3:59 AM.
Tags
None
Referenced Files
F3247549: D5299.diff
Fri, Nov 15, 5:56 AM
Unknown Object (File)
Sat, Nov 9, 8:09 PM
Unknown Object (File)
Sat, Nov 9, 8:09 PM
Unknown Object (File)
Sat, Nov 9, 8:08 PM
Unknown Object (File)
Tue, Nov 5, 2:07 AM
Unknown Object (File)
Oct 5 2024, 11:42 AM
Unknown Object (File)
Oct 5 2024, 11:42 AM
Unknown Object (File)
Oct 5 2024, 11:42 AM

Details

Summary

According to the Rust docs:

Use Result<T, anyhow::Error>, or equivalently anyhow::Result<T>, as the return type of any fallible function.

I replaced all occurrences of anyhow::Result<T, anyhow::Error> with anyhow::Result<T>.

Related Linear issue: ENG-1841

Test Plan
  • Backup service container builds.
  • Integration tests pass.

Diff Detail

Repository
rCOMM Comm
Branch
@barthap/anyhow-result
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek requested review of this revision.Oct 5 2022, 4:10 AM

Documentation states that we can replace Result<T, anyhow::Error> (std::result::Result<T, anyhow::Error>) with anyhow::Result<T>. We are replacing anyhow::Result<T, anyhow::Error> with anyhow::Result<T>. Probably I am missing something since compilation succeeds so definitely not going to block this differential on it.

This revision is now accepted and ready to land.Oct 5 2022, 5:08 AM
This revision now requires review to proceed.Oct 5 2022, 5:09 AM

Documentation states that we can replace Result<T, anyhow::Error> (std::result::Result<T, anyhow::Error>) with anyhow::Result<T>. We are replacing anyhow::Result<T, anyhow::Error> with anyhow::Result<T>. Probably I am missing something since compilation succeeds so definitely not going to block this differential on it.

Good question! According to the docs https://docs.rs/anyhow/latest/anyhow/type.Result.html Result<T> is

equivalent to std::result::Result<T, anyhow::Error>

And Result<T, OtherError> is

equivalent to std::result::Result<T, OtherError>

So anyhow::Result<T> is equivalent to std::result::Result<T, anyhow::Error> which is equivalent to anyhow::Result<T, anyhow::Error>.

This revision is now accepted and ready to land.Oct 6 2022, 1:02 AM