casbin / casbin-rs

An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
https://casbin.org
Apache License 2.0
828 stars 67 forks source link

refactor: use `or_default` instead of `or_insert_with` #315

Open Selflocking opened 1 year ago

Selflocking commented 1 year ago

https://github.com/casbin/casbin-rs/actions/runs/6059164893/job/16441991970

https://rust-lang.github.io/rust-clippy/master/index.html#/unwrap_or_default

codecov[bot] commented 1 year ago

Codecov Report

Merging #315 (a9df29b) into master (b429e4d) will decrease coverage by 0.02%. The diff coverage is 75.00%.

@@            Coverage Diff             @@
##           master     #315      +/-   ##
==========================================
- Coverage   67.64%   67.62%   -0.02%     
==========================================
  Files          24       24              
  Lines        1774     1773       -1     
==========================================
- Hits         1200     1199       -1     
  Misses        574      574              
Files Changed Coverage Δ
src/cached_enforcer.rs 0.00% <0.00%> (ø)
src/config.rs 89.71% <100.00%> (ø)
src/enforcer.rs 70.87% <100.00%> (ø)
src/rbac/default_role_manager.rs 95.16% <100.00%> (-0.03%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

github-actions[bot] commented 1 year ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | **11.6±0.05ms** | 11.8±0.04ms | **-1.69%** | | benchmark priority model | 6.5±0.01µs | 6.5±0.02µs | 0.00% | | benchmark_abac_model | 3.1±0.00µs | 3.1±0.01µs | 0.00% | | benchmark_basic_model | 5.3±0.01µs | 5.3±0.02µs | 0.00% | | benchmark_key_match | 10.7±0.02µs | 10.7±0.03µs | 0.00% | | benchmark_rbac_model | 9.0±0.01µs | **8.8±0.01µs** | **+2.27%** | | benchmark_rbac_model_medium | **1064.4±0.57µs** | 1082.1±7.48µs | **-1.64%** | | benchmark_rbac_model_with_domains | 9.1±0.02µs | 9.1±0.02µs | 0.00% | | benchmark_rbac_with_deny | **11.2±0.03µs** | 11.9±0.01µs | **-5.88%** | | benchmark_rbac_with_resource_roles | 6.6±0.01µs | **6.5±0.02µs** | **+1.54%** | | benchmark_role_manager_large | 4.9±0.00ms | **4.8±0.00ms** | **+2.08%** | | benchmark_role_manager_medium | **420.4±0.17µs** | 423.2±0.20µs | **-0.66%** | | benchmark_role_manager_small | **110.7±0.48µs** | 112.2±0.06µs | **-1.34%** |
github-actions[bot] commented 1 year ago

Benchmark for b429e4d

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | **11.4±0.05ms** | 11.6±0.05ms | **-1.72%** | | benchmark priority model | **6.3±0.01µs** | 6.4±0.01µs | **-1.56%** | | benchmark_abac_model | 3.1±0.01µs | 3.1±0.01µs | 0.00% | | benchmark_basic_model | 5.2±0.02µs | 5.2±0.02µs | 0.00% | | benchmark_key_match | **10.6±0.02µs** | 10.7±0.03µs | **-0.93%** | | benchmark_rbac_model | **8.7±0.02µs** | 8.9±0.03µs | **-2.25%** | | benchmark_rbac_model_medium | 1054.6±4.74µs | 1050.7±11.77µs | +0.37% | | benchmark_rbac_model_with_domains | **8.6±0.01µs** | 8.8±0.02µs | **-2.27%** | | benchmark_rbac_with_deny | 12.0±0.02µs | 12.0±0.02µs | 0.00% | | benchmark_rbac_with_resource_roles | **6.3±0.01µs** | 6.4±0.01µs | **-1.56%** | | benchmark_role_manager_large | 4.9±0.00ms | 4.9±0.00ms | 0.00% | | benchmark_role_manager_medium | **423.9±0.28µs** | 427.4±0.20µs | **-0.82%** | | benchmark_role_manager_small | **109.3±0.59µs** | 110.1±0.10µs | **-0.73%** |