Elixir 到 Rust Actix(七):状态管理——从 Agent/ETS 到 Rust 的选择

在 Elixir 里,状态管理有很多选择:Agent 简单直接,ETS 高性能共享,GenServer 灵活强大。在 Rust 里呢?Arc<Mutex<T>>?DashMap?Actor 状态?每种方案的适用场景是什么?本篇带你梳理清楚。 ...

December 14, 2025 · 7 min · 1420 words · Nanlong

Elixir 到 Rust Actix(六):模式匹配——熟悉的语法,不同的能力

Rust 的模式匹配看起来和 Elixir 很像——都有 match,都能解构,都能用 guard。但用起来,总觉得差点什么。Elixir 的 pin 操作符呢?Rust 为什么不能匹配任意类型?两者的模式匹配,看似相似,实则不同。 ...

December 14, 2025 · 7 min · 1436 words · Nanlong

Elixir 到 Rust Actix(五):容错机制——Let it crash vs 不让你 crash

Elixir 说"崩就崩,有人管"——监督树会重启你。Rust 说"我不让你崩"——编译器会阻止你。两种截然不同的哲学,一个拥抱失败,一个预防失败。什么时候该用哪种? ...

December 14, 2025 · 7 min · 1374 words · Nanlong

Elixir 到 Rust Actix(四):消息传递——从 send 到 Handler

Elixir 的 send 和 receive 简洁优雅——pid ! message,收到就处理,没收到就等。Actix 的消息系统?先定义消息类型,再声明返回类型,然后实现 Handler……为什么同样是发消息,一个三行代码,一个要写一堆 struct 和 impl? ...

December 14, 2025 · 7 min · 1283 words · Nanlong

Elixir 到 Rust Actix(三):进程与并发——spawn 的两种人生

在 Elixir 里,spawn 一个进程就像呼吸一样自然——300 字节,微秒级创建,随便造。在 Rust 里,你要考虑 Actor 还是 tokio::spawn,要不要 Send + 'static,生命周期够不够长……同样是"创建并发执行单元",为什么体验差这么多? ...

December 14, 2025 · 7 min · 1291 words · Nanlong

Elixir 到 Rust Actix(二):Actor 模型——GenServer vs Actix Actor

GenServer 是 Elixir 开发者的老朋友,三个回调函数就能搞定一切。Actix Actor 是它在 Rust 世界的"表亲",但这个表亲要求你先定义消息类型、实现 Handler trait、处理 Result……为什么同样是 Actor,一个简洁优雅,一个"仪式感"满满? ...

December 14, 2025 · 8 min · 1562 words · Nanlong

Elixir 到 Rust Actix(一):同源不同路——两种 Actor 哲学的碰撞

你用 Elixir 写了三年 GenServer,信手拈来。转到 Rust Actix,同样是 Actor 模型,却和编译器吵了三天架。明明是"表亲"技术,为什么感觉像两个世界? ...

December 14, 2025 · 6 min · 1099 words · Nanlong