Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename OptionReport methods #7

Merged
merged 1 commit into from
Feb 26, 2024
Merged

Rename OptionReport methods #7

merged 1 commit into from
Feb 26, 2024

Conversation

mkatychev
Copy link
Contributor

@mkatychev mkatychev commented Feb 26, 2024

Breaking change that renames OptionReport methods:

 pub trait OptionReport {
     type Some;
-    fn ok_or_not_found(self) -> Result<Self::Some, Report<NotFound>>;
-    fn ok_or_not_found_kv<K, V>(self, key: K, value: V) -> Result<Self::Some, Report<NotFound>>
+    fn expect_or(self) -> Result<Self::Some, Report<NotFound>>;
+    fn expect_kv<K, V>(self, key: K, value: V) -> Result<Self::Some, Report<NotFound>>
     where
         K: Display,
         V: Display;
-    fn ok_or_not_found_field(self, field: &'static str) -> Result<Self::Some, Report<NotFound>>;
-    fn ok_or_not_found_by<K: Display>(self, key: K) -> Result<Self::Some, Report<NotFound>>;
+    fn expect_field(self, field: &'static str) -> Result<Self::Some, Report<NotFound>>;
+    fn expect_by<K: Display>(self, key: K) -> Result<Self::Some, Report<NotFound>>;
 }
  • OptionReport::expect_or was used to avoid namespace conflicts with Option::expect
  • This should align it with expect_* macros such as bigerror::expect_field!(my_struct.my_field)?;

@mkatychev mkatychev self-assigned this Feb 26, 2024
@mergify mergify bot added the rename label Feb 26, 2024
Copy link
Contributor

@jsgoyette jsgoyette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change

@mergify mergify bot merged commit 68f76f2 into main Feb 26, 2024
4 checks passed
Copy link
Contributor

mergify bot commented Feb 26, 2024

[✅] @mkatychev: Rename OptionReport methods has been merged successfully.

@mergify mergify bot removed the automerge label Feb 26, 2024
@mergify mergify bot deleted the rename/option_methods branch February 26, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants