refactor: rename method as peel
Some checks failed
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Rust / build (push) Failing after 5m30s

Method on newtypes `unwrap` could be confused with the risky method of
the same name for Option and Result.
This commit is contained in:
Paul Campbell 2024-08-31 10:59:16 +01:00
parent d5d313064a
commit 3f37f82f6a
12 changed files with 13 additions and 13 deletions

View file

@ -18,7 +18,7 @@ impl Handler<NotifyUser> for AlertsActor {
}; };
let net = self.net.clone(); let net = self.net.clone();
let shout = shout.clone(); let shout = shout.clone();
if let Some(user_notification) = self.history.sendable(msg.unwrap()) { if let Some(user_notification) = self.history.sendable(msg.peel()) {
async move { async move {
if let Some(webhook_config) = shout.webhook() { if let Some(webhook_config) = shout.webhook() {
send_webhook(&user_notification, webhook_config, &net).await; send_webhook(&user_notification, webhook_config, &net).await;

View file

@ -7,6 +7,6 @@ impl Handler<UpdateShout> for AlertsActor {
type Result = (); type Result = ();
fn handle(&mut self, msg: UpdateShout, _ctx: &mut Self::Context) -> Self::Result { fn handle(&mut self, msg: UpdateShout, _ctx: &mut Self::Context) -> Self::Result {
self.shout.replace(msg.unwrap()); self.shout.replace(msg.peel());
} }
} }

View file

@ -29,7 +29,7 @@ impl Handler<AdvanceMain> for RepoActor {
let repo_details = self.repo_details.clone(); let repo_details = self.repo_details.clone();
let addr = ctx.address(); let addr = ctx.address();
let message_token = self.message_token; let message_token = self.message_token;
let commit = msg.unwrap(); let commit = msg.peel();
self.update_tui(RepoUpdate::AdvancingMain { self.update_tui(RepoUpdate::AdvancingMain {
commit: commit.clone(), commit: commit.clone(),

View file

@ -28,7 +28,7 @@ impl Handler<AdvanceNext> for RepoActor {
next, next,
main, main,
dev_commit_history, dev_commit_history,
} = msg.unwrap(); } = msg.peel();
let repo_details = self.repo_details.clone(); let repo_details = self.repo_details.clone();
let repo_config = repo_config.clone(); let repo_config = repo_config.clone();
let addr = ctx.address(); let addr = ctx.address();

View file

@ -20,7 +20,7 @@ impl Handler<CheckCIStatus> for RepoActor {
let addr = ctx.address(); let addr = ctx.address();
let forge = self.forge.duplicate(); let forge = self.forge.duplicate();
let next = msg.unwrap(); let next = msg.peel();
let log = self.log.clone(); let log = self.log.clone();
self.update_tui(RepoUpdate::CheckingCI); self.update_tui(RepoUpdate::CheckingCI);

View file

@ -20,7 +20,7 @@ impl Handler<ReceiveCIStatus> for RepoActor {
let log = self.log.clone(); let log = self.log.clone();
logger(log.as_ref(), "start: ReceiveCIStatus"); logger(log.as_ref(), "start: ReceiveCIStatus");
let addr = ctx.address(); let addr = ctx.address();
let (next, status) = msg.unwrap(); let (next, status) = msg.peel();
let forge_alias = self.repo_details.forge.forge_alias().clone(); let forge_alias = self.repo_details.forge.forge_alias().clone();
let repo_alias = self.repo_details.repo_alias.clone(); let repo_alias = self.repo_details.repo_alias.clone();
let message_token = self.message_token; let message_token = self.message_token;

View file

@ -15,7 +15,7 @@ impl Handler<ReceiveRepoConfig> for RepoActor {
type Result = (); type Result = ();
#[instrument(name = "RepoActor::ReceiveRepoConfig", skip_all, fields(repo = %self.repo_details, branches = ?msg))] #[instrument(name = "RepoActor::ReceiveRepoConfig", skip_all, fields(repo = %self.repo_details, branches = ?msg))]
fn handle(&mut self, msg: ReceiveRepoConfig, ctx: &mut Self::Context) -> Self::Result { fn handle(&mut self, msg: ReceiveRepoConfig, ctx: &mut Self::Context) -> Self::Result {
let repo_config = msg.unwrap(); let repo_config = msg.peel();
self.update_tui(RepoUpdate::ReceiveRepoConfig { self.update_tui(RepoUpdate::ReceiveRepoConfig {
repo_config: repo_config.clone(), repo_config: repo_config.clone(),
}); });

View file

@ -26,7 +26,7 @@ impl Handler<ValidateRepo> for RepoActor {
logger(self.log.as_ref(), "start: ValidateRepo"); logger(self.log.as_ref(), "start: ValidateRepo");
// Message Token - make sure we are only triggered for the latest/current token // Message Token - make sure we are only triggered for the latest/current token
match self.token_status(msg.unwrap()) { match self.token_status(msg.peel()) {
TokenStatus::Current => {} // do nothing TokenStatus::Current => {} // do nothing
TokenStatus::Expired => { TokenStatus::Expired => {
logger( logger(

View file

@ -25,7 +25,7 @@ impl Handler<ReceiveAppConfig> for ServerActor {
self.do_send( self.do_send(
ReceiveValidAppConfig::new(ValidAppConfig::new( ReceiveValidAppConfig::new(ValidAppConfig::new(
msg.unwrap(), msg.peel(),
socket_addr, socket_addr,
server_storage, server_storage,
)), )),

View file

@ -26,7 +26,7 @@ impl Handler<ReceiveValidAppConfig> for ServerActor {
app_config, app_config,
socket_address, socket_address,
storage: server_storage, storage: server_storage,
} = msg.unwrap(); } = msg.peel();
// shutdown any existing webhook actor // shutdown any existing webhook actor
if let Some(webhook_actor_addr) = self.webhook_actor_addr.take() { if let Some(webhook_actor_addr) = self.webhook_actor_addr.take() {
webhook_actor_addr.do_send(ShutdownWebhook); webhook_actor_addr.do_send(ShutdownWebhook);

View file

@ -5,6 +5,6 @@ impl actix::Handler<SubscribeToUpdates> for ServerActor {
type Result = (); type Result = ();
fn handle(&mut self, msg: SubscribeToUpdates, _ctx: &mut Self::Context) -> Self::Result { fn handle(&mut self, msg: SubscribeToUpdates, _ctx: &mut Self::Context) -> Self::Result {
self.subscribers.push(msg.unwrap()); self.subscribers.push(msg.peel());
} }
} }

View file

@ -39,13 +39,13 @@ macro_rules! newtype {
} }
#[allow(clippy::missing_const_for_fn)] #[allow(clippy::missing_const_for_fn)]
#[must_use] #[must_use]
pub fn unwrap(self) -> $type { pub fn peel(self) -> $type {
self.0 self.0
} }
} }
impl From<$name> for $type { impl From<$name> for $type {
fn from(value: $name) -> $type { fn from(value: $name) -> $type {
value.unwrap() value.peel()
} }
} }
}; };