Skip to content

Commit

Permalink
Manually implement Deref instead of using derive.
Browse files Browse the repository at this point in the history
  • Loading branch information
travis1829 committed Aug 27, 2022
1 parent 005ff32 commit 8cc3a10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
12 changes: 0 additions & 12 deletions kernel-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions kernel-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default = []
test = []
gicv2 = []
gicv3 = []
lfs = ["dep:derive_deref"]
lfs = []

[profile.dev]
panic = "abort"
Expand All @@ -31,7 +31,6 @@ bitmaps = { version = "3.2.0", default-features = false }
cfg-if = "1.0.0"
const-zero = { git = "https://github.com/maxbla/const-zero.git" }
cstr_core = { version = "0.2.6", default-features = false }
derive_deref = { version = "1.1.1", optional = true }
itertools = { version = "0.10.3", default-features = false }
num-iter = { version = "0.1.43", default-features = false }
pin-project = "1.0.11"
Expand Down
20 changes: 17 additions & 3 deletions kernel-rs/src/fs/lfs/lfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#![allow(clippy::module_inception)]

use core::mem;
use core::ops::Deref;

use derive_deref::Deref;
use pin_project::pin_project;
use spin::Once;
use static_assertions::const_assert;
Expand Down Expand Up @@ -55,7 +55,6 @@ impl<'s> From<&'s BufData> for &'s Checkpoint {

/// A read-only guard of a `SegManager`.
/// Must be `free`d when done using it.
#[derive(Deref)]
pub struct SegManagerReadOnlyGuard<'s>(SleepLockGuard<'s, SegManager>);

impl SegManagerReadOnlyGuard<'_> {
Expand All @@ -64,9 +63,16 @@ impl SegManagerReadOnlyGuard<'_> {
}
}

impl Deref for SegManagerReadOnlyGuard<'_> {
type Target = SegManager;

fn deref(&self) -> &Self::Target {
&self.0
}
}

/// A read-only guard of a `SegManager`.
/// Must be `free`d when done using it.
#[derive(Deref)]
pub struct ImapReadOnlyGuard<'s>(SleepLockGuard<'s, Imap>);

impl ImapReadOnlyGuard<'_> {
Expand All @@ -75,6 +81,14 @@ impl ImapReadOnlyGuard<'_> {
}
}

impl Deref for ImapReadOnlyGuard<'_> {
type Target = Imap;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl Tx<'_, Lfs> {
/// Acquires the lock on the `SegManager` and returns the lock guard.
/// Use this to write blocks to the segment.
Expand Down

0 comments on commit 8cc3a10

Please sign in to comment.