Skip to content

Commit

Permalink
Use the From trait for PageUsage
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Feb 28, 2024
1 parent 821dee2 commit 83e514a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions unified-scheduler-logic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ enum PageUsage {
}
const_assert_eq!(mem::size_of::<PageUsage>(), 8);

impl PageUsage {
fn from_requested_usage(requested_usage: RequestedUsage) -> Self {
impl From<RequestedUsage> for PageUsage {
fn from(requested_usage: RequestedUsage) -> Self {
match requested_usage {
RequestedUsage::Readonly => PageUsage::Readonly(ShortCounter::one()),
RequestedUsage::Writable => PageUsage::Writable,
Expand Down Expand Up @@ -561,7 +561,7 @@ impl SchedulingStateMachine {

fn try_lock_page(page: &PageInner, requested_usage: RequestedUsage) -> LockResult {
match page.usage {
PageUsage::Unused => LockResult::Ok(PageUsage::from_requested_usage(requested_usage)),
PageUsage::Unused => LockResult::Ok(PageUsage::from(requested_usage)),
PageUsage::Readonly(count) => match requested_usage {
RequestedUsage::Readonly => LockResult::Ok(PageUsage::Readonly(count.increment())),
RequestedUsage::Writable => LockResult::Err(()),
Expand Down

0 comments on commit 83e514a

Please sign in to comment.