refactor: rename method as peel
All checks were successful
Rust / build (push) Successful in 9m56s
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
Release Please / Release-plz (push) Successful in 1m25s

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 a2940ec753
14 changed files with 19 additions and 19 deletions

View file

@ -18,7 +18,7 @@ impl Handler<NotifyUser> for AlertsActor {
};
let net = self.net.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 {
if let Some(webhook_config) = shout.webhook() {
send_webhook(&user_notification, webhook_config, &net).await;

View file

@ -7,6 +7,6 @@ impl Handler<UpdateShout> for AlertsActor {
type 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 addr = ctx.address();
let message_token = self.message_token;
let commit = msg.unwrap();
let commit = msg.peel();
self.update_tui(RepoUpdate::AdvancingMain {
commit: commit.clone(),

View file

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

View file

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

View file

@ -20,7 +20,7 @@ impl Handler<ReceiveCIStatus> for RepoActor {
let log = self.log.clone();
logger(log.as_ref(), "start: ReceiveCIStatus");
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 repo_alias = self.repo_details.repo_alias.clone();
let message_token = self.message_token;

View file

@ -15,7 +15,7 @@ impl Handler<ReceiveRepoConfig> for RepoActor {
type Result = ();
#[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 {
let repo_config = msg.unwrap();
let repo_config = msg.peel();
self.update_tui(RepoUpdate::ReceiveRepoConfig {
repo_config: repo_config.clone(),
});

View file

@ -26,7 +26,7 @@ impl Handler<ValidateRepo> for RepoActor {
logger(self.log.as_ref(), "start: ValidateRepo");
// 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::Expired => {
logger(

View file

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

View file

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

View file

@ -5,6 +5,6 @@ impl actix::Handler<SubscribeToUpdates> for ServerActor {
type 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

@ -240,9 +240,9 @@ pub mod given {
}
pub fn a_server_repo_config() -> ServerRepoConfig {
let main = a_branch_name().unwrap();
let next = a_branch_name().unwrap();
let dev = a_branch_name().unwrap();
let main = a_branch_name().peel();
let next = a_branch_name().peel();
let dev = a_branch_name().peel();
ServerRepoConfig::new(
format!("{}/{}", a_name(), a_name()),
main.clone(),

View file

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

View file

@ -716,9 +716,9 @@ mod forgejo {
}
pub fn a_server_repo_config() -> ServerRepoConfig {
let main = a_branch_name().unwrap();
let next = a_branch_name().unwrap();
let dev = a_branch_name().unwrap();
let main = a_branch_name().peel();
let next = a_branch_name().peel();
let dev = a_branch_name().peel();
ServerRepoConfig::new(
format!("{}/{}", a_name(), a_name()),
main.clone(),