Skip to main content

libutils_log/
references.rs

1//^
2//^ HEAD
3//^
4
5//> HEAD -> SUPER
6use super::Log;
7
8//> HEAD -> CORE
9use core::{
10    borrow::Borrow,
11    slice::from_raw_parts as fat
12};
13
14
15//^
16//^ REFERENCES
17//^
18
19//> REFERENCES -> SLICE
20const impl<Type> AsRef<[Type]> for Log<Type> {
21    #[inline]
22    fn as_ref(&self) -> &[Type] {return match self.pointer.take() {
23        None => &[],
24        Some(pointer) => unsafe {fat(pointer.as_ptr(), self.length)}
25    }}
26}
27
28
29//^
30//^ BORROW
31//^
32
33//> BORROW -> CONSTANT
34const impl<Type> Borrow<[Type]> for Log<Type> {
35    #[inline]
36    fn borrow(&self) -> &[Type] {self.as_ref()}
37}