2 releases
0.0.2 | May 26, 2024 |
---|---|
0.0.1 | May 26, 2024 |
#8 in #source-map
245 downloads per month
4MB
1.5K
SLoC
sora
Documentation: https://docs.rs/sora
MSRV: 1.65.0 (3 November, 2022)
License: MIT
lib.rs
:
sora
This crate provides data structures and utilities for working with source maps in Rust.
Getting Started
use sora::SourceMap;
// Load a source map from a buffer
let sm = SourceMap::from(buf).unwrap();
// Find a mapping at the given position (line 10, column 12)
let found = sm.find_mapping((10, 12)).unwrap();
// Print the found mapping
println!("Found mapping at (10, 12): {found}");
// Expected output: "Found mapping at (10, 12): 10:12 -> 1:6:8"
Overview
BorrowedSourceMap
[BorrowedSourceMap] is a source map containing borrowed or owned strings. It allows for efficient parsing and manipulation of source maps, with several methods provided for creating, accessing, and modifying its contents.
SourceMap
[SourceMap] is a source map that owns all its internal strings, providing a more straightforward and safe API for users who do not need to manage the lifetimes of the strings manually.
Position
[Position] represents a 0-based line and 0-based column in a file.
Mapping
[Mapping] presents an item of the mappings
in source maps.
Features
builder
: Enables [SourceMapBuilder] and functions like Mappings::new for manual construction of source maps.index-map
: Enables support for index maps, as specified in spec.extension
: Enables rarely-used source map features as defined in spec, includingignoreList
.
Dependencies
~6MB
~111K SLoC