Skip to content

Commit

Permalink
fix: clippy cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
worapolw committed Nov 16, 2023
1 parent 6cd09aa commit 9ea6ece
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ impl Config {
if section.is_empty() {
section = DEFAULT_SECTION.to_owned();
}
let section_value =
self.data.entry(section).or_insert_with(HashMap::new);
let section_value = self.data.entry(section).or_default();

// if key not exists then insert, else update
let key_value = section_value.get_mut(&option);
Expand Down
6 changes: 3 additions & 3 deletions src/enforcer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl EnforceContext {

impl EventEmitter<Event> for Enforcer {
fn on(&mut self, e: Event, f: fn(&mut Self, EventData)) {
self.events.entry(e).or_insert_with(Vec::new).push(f)
self.events.entry(e).or_default().push(f)
}

fn off(&mut self, e: Event) {
Expand Down Expand Up @@ -151,7 +151,7 @@ impl Enforcer {
self.eft.new_stream(&e_ast.value, max(policy_len, 1));
let m_ast_compiled = self
.engine
.compile_expression(&escape_eval(&m_ast.value))
.compile_expression(escape_eval(&m_ast.value))
.map_err(Into::<Box<EvalAltResult>>::into)?;

if policy_len == 0 {
Expand Down Expand Up @@ -280,7 +280,7 @@ impl Enforcer {
self.eft.new_stream(&e_ast.value, max(policy_len, 1));
let m_ast_compiled = self
.engine
.compile_expression(&escape_eval(&m_ast.value))
.compile_expression(escape_eval(&m_ast.value))
.map_err(Into::<Box<EvalAltResult>>::into)?;

if policy_len == 0 {
Expand Down
7 changes: 2 additions & 5 deletions src/rbac/default_role_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ impl DefaultRoleManager {
) -> NodeIndex<u32> {
let domain = domain.unwrap_or(DEFAULT_DOMAIN);

let graph = self
.all_domains
.entry(domain.into())
.or_insert_with(StableDiGraph::new);
let graph = self.all_domains.entry(domain.into()).or_default();

let role_entry = self
.all_domains_indices
.entry(domain.into())
.or_insert_with(HashMap::new)
.or_default()
.entry(name.into());

let vacant_entry = match role_entry {
Expand Down

0 comments on commit 9ea6ece

Please sign in to comment.