MCPcopy Create free account
hub / github.com/chyyuu/os_kernel_lab / get_ref

Method get_ref

easy-fs/src/block_cache.rs:34–42  ·  view source on GitHub ↗
(&self, offset: usize)

Source from the content-addressed store, hash-verified

32 }
33
34 pub fn get_ref<T>(&self, offset: usize) -> &T
35 where
36 T: Sized,
37 {
38 let type_size = core::mem::size_of::<T>();
39 assert!(offset + type_size <= BLOCK_SZ);
40 let addr = self.addr_of_offset(offset);
41 unsafe { &*(addr as *const T) }
42 }
43
44 pub fn get_mut<T>(&mut self, offset: usize) -> &mut T
45 where

Callers 1

readMethod · 0.45

Calls 1

addr_of_offsetMethod · 0.80

Tested by

no test coverage detected