Skip to main content

expand_roles

Function expand_roles 

Source
pub fn expand_roles(highest_roles: &[Box<str>]) -> String
Expand description

Expands hierarchical roles from highest role to all inherited roles

Given a list of roles (typically just the highest one), this function returns a comma-separated string of all roles from “public” up to and including the highest role in the hierarchy.

§Examples

use cloudillo_types::roles::expand_roles;
assert_eq!(expand_roles(&["moderator".into()]), "public,follower,supporter,contributor,moderator");
assert_eq!(expand_roles(&["contributor".into(), "moderator".into()]), "public,follower,supporter,contributor,moderator");
assert_eq!(expand_roles(&[]), "");