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

了解 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值