mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 06:17:49 +00:00
Run cargo fmt
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -6,10 +6,10 @@
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::{boxed::Box, rc::Rc, vec, vec::Vec};
|
||||
use blog_os::println;
|
||||
use bootloader::{entry_point, BootInfo};
|
||||
use core::panic::PanicInfo;
|
||||
use alloc::{boxed::Box, vec, vec::Vec, rc::Rc};
|
||||
|
||||
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 frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) };
|
||||
|
||||
allocator::init_heap(&mut mapper, &mut frame_allocator)
|
||||
.expect("heap initialization failed");
|
||||
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
|
||||
|
||||
// allocate a number on the heap
|
||||
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
|
||||
let reference_counted = Rc::new(vec![1, 2, 3]);
|
||||
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);
|
||||
println!("reference count is {} now", Rc::strong_count(&cloned_reference));
|
||||
println!(
|
||||
"reference count is {} now",
|
||||
Rc::strong_count(&cloned_reference)
|
||||
);
|
||||
|
||||
#[cfg(test)]
|
||||
test_main();
|
||||
|
||||
Reference in New Issue
Block a user