mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
将 gateway 内部的 model-fetch、provider-transport、scheduler-core、 usage-runtime、video-tasks-core 模块提取为独立 crate;重构 gateway 内部模块结构(state/router/cache/data/query 等);移除大量遗留模块 文件;新增 systemd 二进制部署骨架及相关文档;更新前端 usage 相关 API 和组件。
22 lines
538 B
Rust
22 lines
538 B
Rust
pub fn non_empty_owned(value: Option<&String>) -> Option<String> {
|
|
value
|
|
.map(String::as_str)
|
|
.map(str::trim)
|
|
.filter(|value| !value.is_empty())
|
|
.map(str::to_string)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::non_empty_owned;
|
|
|
|
#[test]
|
|
fn discards_blank_strings() {
|
|
let empty = String::from(" ");
|
|
let value = String::from(" hello ");
|
|
|
|
assert_eq!(non_empty_owned(Some(&empty)), None);
|
|
assert_eq!(non_empty_owned(Some(&value)).as_deref(), Some("hello"));
|
|
}
|
|
}
|