前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Rust日报】 2019-11-17

【Rust日报】 2019-11-17

作者头像
MikeLoveRust
发布2019-11-27 00:21:54
3800
发布2019-11-27 00:21:54
举报

ambassador 程序宏實作的委派 trait (Delegation of trait implementations via procedural macros)

目前只支援 1.40

比如你有貓跟狗都會叫,然後你有個動物enum在上層

想要模仿繼承的感覺,那就是他

代码语言:javascript
复制
use ambassador::{delegatable_trait, Delegate};

#[delegatable_trait]
pub trait Shout {
    fn shout(&self, input: &str) -> String;
}

pub struct Cat;

impl Shout for Cat {
    fn shout(&self, input: &str) -> String {
        format!("{} - meow!", input)
    }
}

pub struct Dog;

impl Shout for Dog {
    fn shout(&self, input: &str) -> String {
        format!("{} - wuff!", input)
    }
}

#[derive(Delegate)]
#[delegate(Shout)]
pub enum Animal {
    Cat(Cat),
    Dog(Dog),
}

pub fn main() {
    let foo_animal = Animal::Cat(Cat);
    println!("{}", foo_animal.shout("BAR"));
}

Read more

repotools rust縮寫指令小工具

git diff, git add -A, git status, git diff --cached, git commit -m <message>, git push and git shortlog -se

dp, aa, st, di, cm, pu and le 取代

Read more

rayn 0.3

SIMD 加速

分形渲染

Read more

MIDI 實體播放器使用 AD9833與 BluePill版子

有人使用了rust結合硬體做了 MIDI 播放器

對嵌入式有興趣的朋友不要錯過了

Read more


From 日报小组 @Damody

日报订阅地址:

独立日报订阅地址:

  • Telgram Channel
  • 阿里云语雀订阅
  • Steemit
  • GitHub

社区学习交流平台订阅:

  • Rust.cc论坛: 支持rss
  • Rust Force: 支持rss
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-11-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Rust语言学习交流 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • ambassador 程序宏實作的委派 trait (Delegation of trait implementations via procedural macros)
  • repotools rust縮寫指令小工具
  • rayn 0.3
  • MIDI 實體播放器使用 AD9833與 BluePill版子
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档