Skip to main content

parse_with_features

Function parse_with_features 

Source
pub fn parse_with_features(
    text: &str,
    allowed: FeatureSet,
) -> Result<(Value, FeatureSet), String>
Expand description

解析 SML 文本,同时限制文档使用的特性子集必须在 allowed 内。

parse_allowed(版本范围)配套:allowed 是调用方(库作者)给出的 白名单,文档内部的 @feature enable/disable 只能收窄这个集合, 不能扩宽——否则文档就能自行绕过调用方的限制。交集为空则报错。

未声明任何 @feature 的文档若仅靠版本基线(如 v3),则基线特性与 allowed 交集;只要交集非空即放行。