Rust.cc

Rust.cc -

【Rust日报】2023-01-14 实验性的跨平台 UI 框架 viewbuilder

clap v4.1 CLI参数解析器clap发布 v4.1,一个小版本。主要改变是错误消息的改进。 v4.1文章链接,https://epage.github.io/blog/2023/01/clap-v4-1/ serde_json_borrow,更快的 JSON 反序列化 通过将 &'ctx str 解析为 Value<'ctx> 尝试引用原始字节,而不是将它们复制到字符串中来减少分配,从而实现更快的 JSON 反序列化。对于ndjson类型的 JSON, serde_json_borrow的解析速度提高了 2 倍。 基准测试 Running benches/crit_bench.rs (/home/pascal/cargo_target_dir/release/deps/crit_bench-fd2d661e0b4255c5) flat-json-to-doc/serde-json-owned time: [352.60 µs 353.40 µs 354.26 µs] thrpt: [236.01 MiB/s 236.59 MiB/s 237.12 MiB/s] flat-json-to-doc/serde-json-borrowed time: [175.53 µs 175.72 µs 175.93 µs] thrpt: [475.23 MiB/s 475.81 MiB/s 476.34 MiB/s] viewbuilder,实验性的跨平台 UI 框架 实验性的跨平台 UI 框架viewbuilder,具有基于 skia 的静态类型树,计划支持 accesskit。 fn counter(count: &mut i32) -> impl View<i32> { container(( text(count.to_string()), container(( button(text("More"), |count| *count += 1), button(text("Less"), |count| *count -= 1), )) )) } pub trait View<T> { type Widget: Widget; fn is_changed(&self, last: &Self) -> bool; fn handle(&mut self, state: &mut T, cx: EventContext<Self::Widget>); fn build(&mut self) -> Self::Widget; fn rebuild(&mut self, last: Self, widget: Self::Widget) -> Self::Widget where Self: Sized, { if self.is_changed(&last) { widget } else { self.build() } } } pub trait Widget { type Layout: Layout; fn paint(&self, context: PaintContext<Self>) where Self: Sized; fn layout(&mut self, taffy: &mut Taffy, scale_factor: f32) -> Self::Layout; } 【2023 Week-2】Rust 视界周刊 本文为 2023 年 Rust 视界周刊第二期。Google 官宣在 Chromium 项目中支持使用 Rust。 原文链接,https://mp.weixin.qq.com/s/HmNsOfNe6O4pOywJt8VZpQ From 日报小组 洋芋 社区学习交流平台订阅: Rust.cc论坛: 支持rss 微信公众号:Rust语言学习交流

相关推荐 去reddit讨论

热榜 Top10

观测云
观测云
LigaAI
LigaAI
eolink
eolink
Dify.AI
Dify.AI

推荐或自荐