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

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的缘由有两个:一、Rust对WebAssembly编译提供了一些最好的支持(稍后会详细介绍),一、咱们想证实 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语言中文社区(rust-china)。
若有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一块儿分享。php

相关文章
相关标签/搜索