pub fn split_into<'a>(
text: &'a str,
records: &mut Vec<&'a str>,
errors: &mut Vec<&'a str>,
)Expand description
拆分到调用者提供的容器以避免每次调用分配。
该函数会清空并填充 records 和 errors。如果调用者在重复调用中重用这些
向量(例如在循环中),则可以避免每次调用分配新的 Vec。
§参数
text- 完整的日志文本records- 用于存储记录切片的向量(会被清空后填充)errors- 用于存储前导错误行的向量(会被清空后填充)
§示例
use dm_database_parser_sqllog::split_into;
let mut records = Vec::new();
let mut errors = Vec::new();
let log_text = r#"2025-08-12 10:57:09.562 (EP[0] sess:1 thrd:1 user:admin trxid:0 stmt:1 appname:MyApp) SELECT 1"#;
split_into(log_text, &mut records, &mut errors);
// 处理 records 和 errors...