🟢 P3 | parse_markdown_separate 多余的 String clone #46
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
ffi_zx_document_ffi_parse_markdown_separate 中 std::str::from_utf8 返回 &str,再 s.to_string() clone 成 String 传给 parse_markdown。parse_markdown 的实际实现只需要 &str(内部标记函数签名为 String 是因为 UniFFI 要求)。
修复方案
保持 to_string()(parse_markdown FFI 签名是 String,若改为 &str 需单独暴露内部接口)。或新增内部 fn parse_markdown_str(s: &str) 让两处调用。
位置
crates/zx_document_ffi/src/lib.rs:189-190
审查结论 (2026-06-06)
结论
to_string()是必要的:crate::parse_markdown()的 FFI 签名要求String(UniFFI#[uniffi::export]不允许&str)。新增内部函数需要改动过大,性价比不高。状态
✅ 无需修改,by design。