Skip to content

Commit

Permalink
refactor type conversion using Into::into
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Dec 8, 2023
1 parent 4f4f968 commit c38ef36
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl Client {
"/api/v0/alerts",
query_params! {
withClosed = *with_closed,
nextId = cursor_opt.map(|cursor| cursor.into()).as_deref().unwrap_or_default(),
nextId = cursor_opt.map(Into::into).as_deref().unwrap_or_default(),
limit = limit.to_string(),
},
request_body![],
Expand Down
6 changes: 3 additions & 3 deletions src/alert_group_setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ pub struct AlertGroupSettingValue {
#[builder(
default,
setter(transform = |service_names: impl IntoIterator<Item = impl Into<ServiceName>>| service_names
.into_iter().map(|service_name| service_name.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub service_scopes: Vec<ServiceName>,
#[builder(
default,
setter(transform = |role_fullnames: impl IntoIterator<Item = impl Into<RoleFullname>>| role_fullnames
.into_iter().map(|role_fullname| role_fullname.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub role_scopes: Vec<RoleFullname>,
#[builder(
default,
setter(transform = |monitor_ids: impl IntoIterator<Item = impl Into<MonitorId>>| monitor_ids
.into_iter().map(|monitor_id| monitor_id.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub monitor_scopes: Vec<MonitorId>,
Expand Down
12 changes: 6 additions & 6 deletions src/downtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,42 @@ pub struct DowntimeValue {
#[builder(
default,
setter(transform = |service_names: impl IntoIterator<Item = impl Into<ServiceName>>| service_names
.into_iter().map(|service_name| service_name.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub service_scopes: Vec<ServiceName>,
#[builder(
default,
setter(transform = |service_names: impl IntoIterator<Item = impl Into<ServiceName>>| service_names
.into_iter().map(|service_name| service_name.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub service_exclude_scopes: Vec<ServiceName>,
#[builder(
default,
setter(transform = |role_fullnames: impl IntoIterator<Item = impl Into<RoleFullname>>| role_fullnames
.into_iter().map(|role_fullname| role_fullname.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub role_scopes: Vec<RoleFullname>,
#[builder(
default,
setter(transform = |role_fullnames: impl IntoIterator<Item = impl Into<RoleFullname>>| role_fullnames
.into_iter().map(|role_fullname| role_fullname.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub role_exclude_scopes: Vec<RoleFullname>,
#[builder(
default,
setter(transform = |monitor_ids: impl IntoIterator<Item = impl Into<MonitorId>>| monitor_ids
.into_iter().map(|monitor_id| monitor_id.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub monitor_scopes: Vec<MonitorId>,
#[builder(
default,
setter(transform = |monitor_ids: impl IntoIterator<Item = impl Into<MonitorId>>| monitor_ids
.into_iter().map(|monitor_id| monitor_id.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub monitor_exclude_scopes: Vec<MonitorId>,
Expand Down
2 changes: 1 addition & 1 deletion src/graph_annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct GraphAnnotationValue {
#[builder(
default,
setter(transform = |role_names: impl IntoIterator<Item = impl Into<RoleName>>| role_names
.into_iter().map(|role_name| role_name.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub roles: Vec<RoleName>,
Expand Down
17 changes: 7 additions & 10 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub struct HostValue {
#[builder(
default,
setter(transform = |role_fullnames: impl IntoIterator<Item = impl Into<RoleFullname>>| role_fullnames
.into_iter().map(|role_fullname| role_fullname.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub role_fullnames: Vec<RoleFullname>,
Expand All @@ -129,14 +129,14 @@ pub struct HostInterface {
#[builder(
default,
setter(transform = |ipv4_addresses: impl IntoIterator<Item = impl Into<Ipv4Addr>>| ipv4_addresses
.into_iter().map(|ipv4_address| ipv4_address.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub ipv4_addresses: Vec<Ipv4Addr>,
#[builder(
default,
setter(transform = |ipv6_addresses: impl IntoIterator<Item = impl Into<Ipv6Addr>>| ipv6_addresses
.into_iter().map(|ipv6_address| ipv6_address.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub ipv6_addresses: Vec<Ipv6Addr>,
Expand Down Expand Up @@ -395,10 +395,7 @@ impl ListHostsParams {
) -> Self {
Self {
service_name: Some(service_name.into()),
role_names: role_names
.into_iter()
.map(|role_name| role_name.into())
.collect::<Vec<_>>(),
role_names: role_names.into_iter().map(Into::into).collect::<Vec<_>>(),
..Self::default()
}
}
Expand Down Expand Up @@ -569,7 +566,7 @@ impl Client {
request_body! {
ids: Vec<HostId> = host_ids
.into_iter()
.map(|host_id| host_id.into())
.map(Into::into)
.collect::<Vec<_>>(),
status: HostStatus = host_status,
},
Expand All @@ -593,7 +590,7 @@ impl Client {
request_body! {
roleFullnames: Vec<RoleFullname> = role_fullnames
.into_iter()
.map(|role_fullname| role_fullname.into())
.map(Into::into)
.collect::<Vec<_>>(),
},
response_body!(),
Expand Down Expand Up @@ -629,7 +626,7 @@ impl Client {
request_body! {
ids: Vec<HostId> = host_ids
.into_iter()
.map(|host_id| host_id.into())
.map(Into::into)
.collect::<Vec<_>>(),
},
response_body!(),
Expand Down
4 changes: 2 additions & 2 deletions src/notification_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ pub struct NotificationGroupValue {
#[builder(
default,
setter(transform = |notification_group_ids: impl IntoIterator<Item = impl Into<NotificationGroupId>>| notification_group_ids
.into_iter().map(|notification_group_id| notification_group_id.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
pub child_notification_group_ids: Vec<NotificationGroupId>,
#[builder(
default,
setter(transform = |channel_ids: impl IntoIterator<Item = impl Into<ChannelId>>| channel_ids
.into_iter().map(|channel_id| channel_id.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
pub child_channel_ids: Vec<ChannelId>,
#[builder(default)]
Expand Down
2 changes: 1 addition & 1 deletion src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Service {
#[builder(
default,
setter(transform = |role_names: impl IntoIterator<Item = impl Into<RoleName>>| role_names
.into_iter().map(|role_name| role_name.into()).collect::<Vec<_>>()),
.into_iter().map(Into::into).collect::<Vec<_>>()),
)]
pub roles: Vec<RoleName>,
}
Expand Down

0 comments on commit c38ef36

Please sign in to comment.