ITPub博客

首页 > 数据库 > 数据库开发技术 > 【Rust日报】 2020-06-12 了解 Fuchsia 的 Rust 开发

【Rust日报】 2020-06-12 了解 Fuchsia 的 Rust 开发

原创 数据库开发技术 作者:Rust语言中文社区 时间:2020-06-13 18:53:06 0 删除 编辑

了解 Fuchsia 的 Rust 开发

Fuchsia 是 Google 正在开发的一个开源操作系统,最近 fuchsia.dev 上最近更新了很多开发文档,其中 Rust 开发文档最近于 2020-06-10 更新。在已经开放的开发文档里面,Rust 文档相对来说还是比较丰富的,相应的公开讨论频道在:rust@fuchsia.com。
了解更多详情或者查看文档请看:https://fuchsia.dev/fuchsia-src/development/languages/rust
reddit 上参与讨论:https://www.reddit.com/r/rust/comments/h7dkv2/rust_fuchsia/

GameLisp

GameLisp 是一个用于 Rust 游戏开发的脚本语言。了解详情请看:https://gamelisp.rs/

Shredder 项目

Shredder 项目主要针对于 Rust 的智能指针的“垃圾回收”,更多细节请看博客原文:https://blog.typingtheory.com/shredder-garbage-collection-as-a-library-for-rust/
项目地址:https://github.com/Others/shredder

derive_aktor

derive_aktor 是一个宏库,使用起来还是挺方便的,项目地址:https://github.com/insanitybit/derive_aktor
使用示例:
pub struct KeyValueStore<U>    where U: Hash + Eq + Send + 'static{    inner_store: HashMap<U, String>,    self_actor: Option<KeyValueStoreActor<U>>,}
impl<U: Hash + Eq + Send + 'static> KeyValueStore<U> { pub fn new() -> Self { Self { inner_store: HashMap::new(), self_actor: None, } }}
// All methods in this block form our Actor's API#[derive_actor]impl<U: Hash + Eq + Send + 'static> KeyValueStore<U> { pub fn query(&self, key: U, f: Box<dyn Fn(Option<String>) + Send + 'static>) { println!("query"); f(self.inner_store.get(&key).map(String::from)) }
pub fn set(&mut self, key: U, value: String) { println!("set"); self.inner_store.insert(key, value); }}

#[tokio::main]async fn main() {
let (kv_store, handle) = KeyValueStoreActor::new(KeyValueStore::new()).await; // We can use an async API that's typed and nominal kv_store.query("foo", Box::new(|value| println!("before {:?}", value))).await; kv_store.set("foo", "bar".to_owned()).await; kv_store.query("foo", Box::new(|value| println!("after {:?}", value))).await;
// We must drop any references to kv_store before we await the handle, or it will leak!
drop(kv_store); handle.await;}


From 日报小组 @Jancd

原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2020-06-11

  • 博文量
    1769
  • 访问量
    718398