/
githubmirror
/
servo
Обзор
Документация
Войти
/
githubmirror
/
servo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
components/xpath/src/context.rs
38 строк
1 KB
Simon Wülker
xpath: Replace `nom` with hand-written parsing rules (#39977)
25 окт 2025, 06:23
Не верифицирован
25 окт 2025, 06:23
7485978
Код
Авторство
О чём код?
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::Dom; /// The context during evaluation of an XPath expression. #[derive(Debug)] pub(crate) struct EvaluationCtx<D: Dom> { /// The "current" node in the evaluation. pub(crate) context_node: D::Node, /// Details needed for evaluating a predicate list. pub(crate) predicate_ctx: Option<PredicateCtx>, } #[derive(Clone, Copy, Debug)] pub(crate) struct PredicateCtx { pub(crate) index: usize, pub(crate) size: usize, } impl<D: Dom> EvaluationCtx<D> { /// Prepares the context used while evaluating the XPath expression. pub(crate) fn new(context_node: D::Node) -> Self { EvaluationCtx { context_node, predicate_ctx: None, } } /// Creates a new context using the provided node as the context node. pub(crate) fn subcontext_for_node(&self, node: D::Node) -> Self { EvaluationCtx { context_node: node, predicate_ctx: self.predicate_ctx, } } }