【Rust日报】2023-01-18 希望你能早点学到的 Rust 技巧
2023-03-07 09:14:38 时间
希望你能早点学到的 Rust 技巧
- 双向引用
- 实现 Deref
- 小心实现 Deref
- 内部可变性的使用
- 接受 unsafe
- ...
ReadMore: https://rauljordan.com/rust-concepts-i-wish-i-learned-earlier/
tantivy - Rust 编写的全文搜索引擎库
这个项目允许按每个线程和每个回溯实时内存剖析。
tantivy更接近Apache Lucene,而不是Elasticsearch或Apache Solr。他不是一个现成的搜索引擎服务器,而是一个 crates 。
Tantivy的灵感来自Lucene的设计。
ReadMore:https://github.com/quickwit-oss/tantivy
Type-erasing trait parameters in Rust
- Rust 中的基本类型擦除
- 使用类型参数进行类型擦除
- 擦除所有类型参数
- ...
例子
#[tokio::main]
async fn main() {
let mut service_map = ServiceMap::default();
service_map.register(Foo {});
service_map.register(Bar {});
// prints: "got i64: 123"
service_map.call(123i64).await;
// prints: Point(123.0, 456.0)
service_map.call((123.0f64, 456.0f64)).await;
// prints nothing, since no service has been registered for `Request = &str`
service_map.call("str").await;
}
struct Foo {}
impl Service<i64> for Foo {
type Response = String;
type Future = Ready<String>;
fn call(&mut self, req: i64) -> Ready<String> {
ready(format!("got i64: {req:?}"))
}
}
#[derive(Debug)]
struct Point(f64, f64);
struct Bar {}
impl Service<(f64, f64)> for Bar {
type Response = Point;
type Future = Ready<Point>;
fn call(&mut self, req: (f64, f64)) -> Ready<Point> {
ready(Point(req.0, req.1))
}
}
ReadMore:https://fredrik.space/posts/rust-erased-trait-parameters
相关文章
- Amazon Polly 让 WordPress 有了自己的声音!
- 使用全新 Amazon Polly 插件,让您的 WordPress 博客变有声
- Model Server for Apache MXNet 引入 ONNX 支持和 Amazon CloudWatch 集成
- 基于ECS的容器日志解决方案
- Amazon SageMaker 现在推出了 AWS CloudTrail 集成
- 借助 Microsoft Excel 构建 Amazon Lex 聊天机器人
- 全新 AWS Auto Scaling – 适用于云应用程序的统一扩展
- 为您的聊天机器人部署 Web UI
- 限制门槛已解除 – EC2 实例的网络带宽增加
- AWS DeepLens Lambda 函数与新 Model Optimizer 详解
- Amazon SageMaker BlazingText:在多个 CPU 或 GPU 上并行处理 Word2Vec
- 使用 NNPACK 库加速 Apache MXNet
- 新功能 – 区域间 VPC 对等连接
- ClearView Social 使用 Amazon Comprehend 来衡量社交分享的影响力
- 最新 EC2 好东西 – 启动模板与分布置放
- 利用机器学习和 BI 服务构建社交媒体控制面板
- AWS Organizations —— 管理众多账号再也不是难题
- 现已开放 – 伦敦的第三个 AWS 可用区
- 搭建DX Gateway,轻松互联全球架构
- 使用 AWS Glue 和 Amazon Athena 实现无服务器的自主型机器学习