pub fn parse_with_notation(with: &str) -> (&str, Option<&str>)Expand description
解析 PHP with() 嵌套关系语法
对齐 PHP RelationShip::eagerlyResultSet 第 266-270 行:
if (strpos($relation, '.')) {
[$relation, $subRelation] = explode('.', $relation, 2);
$subRelation = [$subRelation];
}§参数
with:关系名字符串(如"category"或"items.product")
§返回
(主关系名, Option<子关系名>),子关系名为 Some 时表示存在嵌套。
§示例
ⓘ
use sz_rust_core::relation::with::parse_with_notation;
assert_eq!(parse_with_notation("category"), ("category", None));
assert_eq!(parse_with_notation("items.product"), ("items", Some("product")));
assert_eq!(parse_with_notation("a.b.c"), ("a", Some("b.c"))); // 仅按第一个 . 分割