Run cargo fmt

This commit is contained in:
Philipp Oppermann
2019-06-26 16:59:38 +02:00
parent e5b6ba38ac
commit 5cf3884396

View File

@@ -6,10 +6,10 @@
extern crate alloc; extern crate alloc;
use alloc::{boxed::Box, rc::Rc, vec, vec::Vec};
use blog_os::println; use blog_os::println;
use bootloader::{entry_point, BootInfo}; use bootloader::{entry_point, BootInfo};
use core::panic::PanicInfo; use core::panic::PanicInfo;
use alloc::{boxed::Box, vec, vec::Vec, rc::Rc};
entry_point!(kernel_main); entry_point!(kernel_main);
@@ -23,8 +23,7 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
let mut mapper = unsafe { memory::init(boot_info.physical_memory_offset) }; let mut mapper = unsafe { memory::init(boot_info.physical_memory_offset) };
let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) }; let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) };
allocator::init_heap(&mut mapper, &mut frame_allocator) allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
.expect("heap initialization failed");
// allocate a number on the heap // allocate a number on the heap
let heap_value = Box::new(41); let heap_value = Box::new(41);
@@ -40,9 +39,15 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
// create a reference counted vector -> will be deallocated when count reaches 0 // create a reference counted vector -> will be deallocated when count reaches 0
let reference_counted = Rc::new(vec![1, 2, 3]); let reference_counted = Rc::new(vec![1, 2, 3]);
let cloned_reference = reference_counted.clone(); let cloned_reference = reference_counted.clone();
println!("current reference count is {}", Rc::strong_count(&cloned_reference)); println!(
"current reference count is {}",
Rc::strong_count(&cloned_reference)
);
core::mem::drop(reference_counted); core::mem::drop(reference_counted);
println!("reference count is {} now", Rc::strong_count(&cloned_reference)); println!(
"reference count is {} now",
Rc::strong_count(&cloned_reference)
);
#[cfg(test)] #[cfg(test)]
test_main(); test_main();