srgn 0.14.2

A grep-like tool which understands source code syntax and allows for manipulation in addition to search
Documentation
//! Items for defining the scope actions are applied within.

use scope::RangesWithContext;

use crate::scoping::scope::ROScopes;
#[cfg(doc)]
use crate::scoping::{scope::Scope, view::ScopedView};

/// Fixes for DOS-style line endings.
pub mod dosfix;
/// Create scoped views using programming language grammar-aware types.
pub mod langs;
/// Create scoped views using string literals.
pub mod literal;
/// Create scoped views using regular expressions.
pub mod regex;
/// [`Scope`] and its various wrappers.
pub mod scope;
/// [`ScopedView`] and its related types.
pub mod view;

/// An item capable of scoping down a given input into individual scopes.
pub trait Scoper: Send + Sync {
    /// Scope the given `input`.
    ///
    /// After application, the returned scopes are a collection of either in-scope or
    /// out-of-scope parts of the input. Assembling them back together should yield the
    /// original input.
    fn scope<'viewee>(&self, input: &'viewee str) -> ROScopes<'viewee> {
        let ranges = self.scope_raw(input);

        ROScopes::from_raw_ranges(input, ranges)
    }

    /// Scope the given `input`, returning raw ranges.
    ///
    /// Raw ranges are those not turned into [`ROScopes`] yet.
    fn scope_raw<'viewee>(&self, input: &'viewee str) -> RangesWithContext<'viewee>;
}