【Rust 日报】2023-1-20 西门子在一次内部Rust Meetup上介绍了Rust在列车控制网络中的应用
2023-03-07 09:14:39 时间
推上说西门子在一次内部Rust Meetup上介绍了Rust在列车控制网络中的应用
Daniel Bovensiepen Li @bovensiepen Today's Rust Meetup at Siemens introduced the application of Rust in train control networks. Things are moving ?
https://twitter.com/bovensiepen/status/1616367973475966976
Coerce-rs Actor模型分布式应用框架
使用它你可以方便地实现基于Actor模型的分布式系统。
https://github.com/LeonHartley/Coerce-rs
justjson - 又一个rust json parser
已有的框架不满足作者的需求,一怒之下自己造了一个。所说性能还很好(当然评测是有技巧的)。
https://ecton.dev/rust-json-ecosystem/
Rust操作符重载可以玩出什么花样?
下面是6个例子:
## C++ Input/Output
Instead of
stdin().read_line(&mut buffer).unwrap();
println!("Hello I am {name}!!!");
we can overload the shift operators on cin and cout to allow
cin >> &mut buffer;
cout << "Hello I am " << name << "!!!" << endl;
## Variadic Functions
Instead of
std::cmp::max(x, y);
[w, x, y, z].into_iter().max();
we can make
// max+ is like std::cmp::max but better
// it supports >2 arguments
max+(x, y);
max+(w, x, y, z);
## More Concise Builders
Here's a more serious one. Builder pattern sometimes involve a lot of repeated method calls. Take for example this usage of the warp web framework.
let hi = warp::path("hello")
.and(warp::path::param())
.and(warp::header("user-agent"))
.map(|param: String, agent: String| {
format!("Hello {}, whose agent is {}", param, agent)
});
What if the API look like this instead?
let hi = warp::path("hello")
+ warp::path::param()
+ warp::header("user-agent")
>> |param: String, agent: String| {
format!("Hello {}, whose agent is {}", param, agent)
};
## Infix Functions
Instead of
x.pow(y);
dot_product(a, b);
a.cross(b.cross(c).cross(d))
we can make
x ^pow^ y;
a *dot* b;
a *cross* (b *cross* c *cross* d);
Lots of people wanted this!
## Doublefish
std::mem provides these functions
size_of::<T>();
size_of_val(&value);
Turbofish enthusiasts would enjoy size_of but not so much size_of_val, so let's make our own improved version of size_of_val that's more turbofishy
size_of::<T>();
size_of_val<<&value>>();
## Join and Race
Futures combinators can have short-circuiting behaviors
// quit if any of the 3 errors
(fut1, fut2, fut3).try_join().await;
// quit if any of the 3 succeeds
(fut4, fut5, fut6).race_ok().await;
let's communicate this through & and |
(TryJoin >> fut1 & fut2 & fut3).await;
(RaceOk >> fut4 | fut5 | fut6).await;
https://wishawa.github.io/posts/fun-rust-operators/
相关文章
- LibreOffice 7.5 发布:漂亮的新应用图标和酷炫功能
- elementary OS 7 发布
- Windows 应用兼容层 Wine 8.1 发布:默认启用“Windows 10”前缀
- 微软正测试新功能:当 Windows 11 有新的小组件可用时会提醒通知
- 解析分布式存储选型和应用九个典型问题
- ClickHouse在自助行为分析场景的实践应用
- Chrome DevTools 远程调试安卓网页的原理
- Uni-app + Vue3 页面如何跳转及传参?
- 微软证实系统还原点会损坏 Windows 11 22H2 版本应用程序
- 巧用 Transition 实现短视频 APP 点赞动画
- 初学者试试,HarmonyOS应用开发者基础认证
- 媒体实测微软 Windows 开发工具包 2023:存在不兼容 HDR 显示器、某些应用无法运行等问题
- 快速了解Navigator API SetAppBadge
- 微软 Windows 11 Dev 预览版 Build 25276 发布,应用兼容问题对话框 UI 改进
- 基于Next.js、Prisma、Postgres和Fastfy构建全栈APP
- 开始菜单搜索框变圆角,微软 Windows 11 Beta 预览版 22621.1095 和 22623.1095 发布
- 2022-2023 十大应用开发趋势
- 观远数据发布业内首部《移动BI白皮书》,深入业务数字化场景重新定义移动BI
- Windows 10 学院:不借助第三方工具如何卸载 Windows 10 预装应用
- 正处高质量发展期,我国大数据产业突破1.3万亿元