ITPub博客

首页 > 数据库 > 数据库开发技术 > 【Rust日报】2020-04-09 200行代码讲透Rust Futures

【Rust日报】2020-04-09 200行代码讲透Rust Futures

原创 数据库开发技术 作者:Rust语言中文社区 时间:2020-04-10 12:33:47 0 删除 编辑

200行代码讲透 Rust Futures

这是一个比较长的博客,主要是用一个例子驱动的方法来解释Rust中的Futures,探索为什么他们被设计成这样,以及他们如何工作,此外还介绍在编程中处理并发性时的一些替代方案。
原文地址:https://cfsamson.github.io/books-futures-explained/introduction.html,同时国内的大佬 白振轩的个人博客已经做了翻译,请看:https://stevenbai.top/rust/futures_explained_in_200_lines_of_rust/

Rust 是 k8s 的不错选择

前些天,我们日报小组介绍了 Krustlet,这是 Rust 中一个基于 WebAssembly 的 Kubelet 实现。我们选择使用Rust的原因有两个:1、Rust对WebAssembly编译提供了一些最好的支持(稍后会详细介绍),1、我们想证明 Rust 的优势可以应用于 Kubernetes 生态系统。这篇文章旨在表明我们学到了什么以及为什么我们认为 Rust 是编写 Kubernetes 重点应用程序的绝佳选择(有时更好)【来自(DeisLabs)的博客】。
原文请看:https://deislabs.io/posts/kubernetes-a-rusty-friendship/

proc-macro-error

proc-macro-error 的目标是使过程宏中的错误报告变得轻松便捷。
使用实例速览:
use proc_macro_error::*;use proc_macro::TokenStream;use syn::{spanned::Spanned, DeriveInput, ItemStruct, Fields, Attribute , parse_macro_input};use quote::quote;
fn process_attrs(attrs: &[Attribute]) -> Vec<Attribute> { attrs .iter() .filter_map(|attr| match process_attr(attr) { Ok(res) => Some(res), Err(msg) => { emit_error!(attr, "Invalid attribute: {}", msg); None } }) .collect()}
fn process_fields(_attrs: &Fields) -> Vec<TokenStream> { // processing fields in pretty much the same way as attributes unimplemented!()}
#[proc_macro]#[proc_macro_error]pub fn make_answer(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as ItemStruct); let attrs = process_attrs(&input.attrs);
// abort right now if some errors were encountered // at the attributes processing stage abort_if_dirty();
let fields = process_fields(&input.fields);
// no need to think about emitted errors // #[proc_macro_error] will handle them for you // // just return a TokenStream as you normally would quote!(/* stuff */).into()}
仓库地址:https://gitlab.com/CreepySkeleton/proc-macro-error


From 日报小组 @Jancd

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

请登录后发表评论 登录
全部评论

注册时间:2020-06-11

  • 博文量
    1769
  • 访问量
    718717