Build a human-readable label for the subject, used in success messages.
(
subject_type: atomic_teams::GrantSubjectType,
team_slug: &Option<String>,
user_id: &Option<String>,
)
| 340 | |
| 341 | /// Build a human-readable label for the subject, used in success messages. |
| 342 | fn subject_label( |
| 343 | subject_type: atomic_teams::GrantSubjectType, |
| 344 | team_slug: &Option<String>, |
| 345 | user_id: &Option<String>, |
| 346 | ) -> String { |
| 347 | match subject_type { |
| 348 | atomic_teams::GrantSubjectType::Team => { |
| 349 | format!("team '{}'", team_slug.as_deref().unwrap_or("?")) |
| 350 | } |
| 351 | atomic_teams::GrantSubjectType::User => { |
| 352 | format!("user {}", user_id.as_deref().unwrap_or("?")) |
| 353 | } |
| 354 | atomic_teams::GrantSubjectType::Everyone => "everyone".to_string(), |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | #[cfg(test)] |
| 359 | mod tests { |
no outgoing calls