< 返回版块

洋芋 发表于 2021-09-11 23:33

Tags:rust, 日报

Tabled 发布v0.3

Tabled 是一个易于使用的库,用于美化 Rust 结构和枚举的输出。

Github链接,https://github.com/zhiburt/tabled

bma-benchmark 一个友好的基准测试工具

使用 bma_benchmark

#[macro_use]
extern crate bma_benchmark;

use std::sync::Mutex;

let n = 100_000_000;
let mutex = Mutex::new(0);
benchmark_start!();
for _ in 0..n {
    let _a = mutex.lock().unwrap();
}
benchmark_print!(n);

使用宏 benchmark!

#[macro_use]
extern crate bma_benchmark;

use std::sync::Mutex;

let mutex = Mutex::new(0);
benchmark!(100_000_000, {
    let _a = mutex.lock().unwrap();
    });

结果

Crate 链接,https://crates.io/crates/bma-benchmark

ferros

seL4 是一个用于构建操作系统和嵌入式程序的工具包,这个开源项目是使 Rust 中的 seL4 编程变得更好。

以下代码演练假定使用示例 sel4_start 库执行 selfe,并介绍了 ferros 的某些方面。

use selfe_sys;
use ferros::alloc::{self, micro_alloc, smart_alloc};
use ferros::userland::{root_cnode, BootInfo};

// The raw boot info is provided by the sel4_start library
let raw_boot_info: &'static selfe_sys::seL4_BootInfo = unsafe { &*sel4_start::BOOTINFO };


// Utility for finding and claiming `Untyped` instances supplied by the boot info.
let mut allocator = micro_alloc::Allocator::bootstrap(&raw_boot_info)?;
let initial_untyped = allocator
    .get_untyped::<U20>() // The size of the Untyped instance, as bits
    .expect("Couldn't find an untyped instance of the desired size");

// Create the top-level CNode wrapper with type-level-tracked remaining slot capacity
let (root_cnode, local_slots) = root_cnode(&raw_boot_info);

// Once we have an initial Untyped instance, memory distribution from it
// can be tracked with compile-time checks. The smart_alloc macro synthesizes
// the allocation code, and the capacity bounds are statically verified by
// the type checker. The effect is that you can write 'slots' in the macro body 
// anywhere you need some slots, and you'll get the right number allocated
// with type inference. A reference to 'ut' does the same for untyped memory. 
smart_alloc!(|slots from local_slots, ut from uts| {

    // Create a page table seL4 kernel object and return a capability pointer to it.
    // Here we use a variable binding type annotation and Rust's type system can figure out
    // if it can allocate a large enough Untyped instance and enough cnode slots
    // to represent this particular kernel object.
    let example_page_table: LocalCap<UnmappedPageTable> = retype(ut, slots)?;

    // Create a resource-tracking wrapper around the raw boot info to assist in
    // virtual memory related operations.
    let boot_info  = BootInfo::wrap(raw_boot_info, ut, slots);
    let (root_page_table, boot_info) = boot_info.map_page_table(root_page_table)?;
});

Github链接,https://github.com/auxoncorp/ferros

Veloren发布v0.11

今天,Veloren 发布了 0.11。 这个版本已经制作了 3 个月,其一大重点是让世界各地的战斗更具活力。这是以新的地点系统的形式出现,以及 NPC 和生物如何与世界互动。

要了解还有哪些新功能!请继续阅读 V0.11 变更日志链接,https://veloren.net/release-0-11/


From 日报小组 洋芋

社区学习交流平台订阅:

评论区

写评论

还没有评论

1 共 0 条评论, 1 页