similar

A dependency-free Rust diffing library with Myers, Patience, Histogram, and LCS algorithms

Library
Cargo
v3.2.0
1,331 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
69 /100 Good
Development Activity 84
Maintenance 44
Community 48
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 80
Code Quality 78
Innovation 75
Learning Curve 72

similar is a Rust crate that implements multiple diffing algorithms (Myers, Patience, Hunt-style, Histogram, and classic LCS) behind a single high-level API for comparing arbitrary sequences. It was originally inspired by pijul’s diff implementation and was built to power the insta snapshot testing library, but works equally well as a general-purpose diffing toolkit for text, byte, or custom sequence data.

The crate exposes both a low-level capture_diff/capture_diff_slices interface for diffing any indexable sequence, and a higher-level TextDiff type purpose-built for text: line, word, character, and grapheme-level diffing, unified diff generation, and inline change highlighting. It supports no_std + alloc environments via optional hashbrown/bstr backends, making it usable outside of a standard host environment.

What You Get

  • Multiple diff algorithm implementations (Myers, Patience, Hunt-style, Histogram, classic LCS table) selectable via a single Algorithm enum
  • A high-level TextDiff API for line, word, character, and grapheme-level text comparison
  • Unified diff generation (udiff module) compatible with standard patch/diff tooling
  • Inline change highlighting for rendering fine-grained word/character differences within a changed line
  • no_std + alloc support with pluggable hashbrown/bstr backends for embedded or constrained environments
  • Generic sequence diffing via capture_diff/capture_diff_slices for any indexable, non-text data

Common Use Cases

  • Powering snapshot-testing tools that need to show human-readable diffs between expected and actual output (its original use case in insta)
  • Generating unified diffs for CLI tools, patch utilities, or code-review tooling
  • Building custom diff/merge views in editors or terminal UIs with word- or character-level highlighting
  • Comparing arbitrary structured sequences (not just text) in data-processing or testing pipelines

Under The Hood

Architecture - similar is organized around a low-level algorithms module that implements each diff algorithm (Myers in myers.rs, Patience in patience.rs, Histogram in histogram.rs, Hunt-style in hunt.rs, and classic LCS in lcs.rs) behind a shared capture_diff/capture_diff_slices entry point that operates on any indexable sequence via a CachedLookup abstraction (lookup.rs). Text-specific functionality sits in the text module, where TextDiff (abstraction.rs) wraps the generic algorithms with tokenization for line/word/character/grapheme granularity, and InlineChange (inline.rs) layers word-level highlighting on top of a line-level diff. udiff.rs renders DiffOp sequences produced by the core algorithms into standard unified-diff text. Tech Stack - the crate has zero mandatory dependencies; optional features add unicode-segmentation for grapheme-aware splitting, bstr for byte-string handling, hashbrown/web-time for no_std + alloc targets, and serde for serializing diff ops. Dev-dependencies (insta, criterion) show the crate dogfoods its own downstream consumer (insta) for its test suite and benchmarks. Code Quality - tests are implemented as snapshot tests via insta, with committed .snap files under src/snapshots/ and src/text/snapshots/ covering unified-diff output and text-diff behavior; there is no separate tests/ integration directory, so most correctness checking happens through these snapshots plus the benches/diffs.rs Criterion benchmark. Code is split into small, single-responsibility files per algorithm rather than one large module, aiding readability. API Design - the public surface favors a small number of top-level entry points (TextDiff::from_lines, capture_diff_slices, Algorithm enum) with sensible defaults (Myers algorithm, line-terminated diffing) so a consumer can get a working unified diff in under 10 lines, while lower-level access to DiffOps remains available for callers that need custom rendering.

Used by 8 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

AI Assistants · Collaboration · Productivity

76,967

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
67
Dependency
Built with
Dart 74%
Rust 24%
Updated 1 weeks ago
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,285

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated 5 days ago
Rust
72%
MIT

monty

AI Development · Developer Tools

8,362

Run LLM-generated Python code safely inside your agent—no containers, no CPython, no compromise—with sub-microsecond startup.

View details
87
Repo Health
83
Technical
73
Dependency
Built with
Rust 72%
Python 23%
Updated 5 days ago
Go
81%
AGPL 3.0

PeerDB

Data Engineering · Databases

3,288

Postgres-native ETL that streams change data capture in real time to Snowflake, BigQuery, ClickHouse, S3, and Kafka — up to 10x faster than general-purpose pipelines, managed through a familiar Postgres SQL interface.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
Go 81%
TypeScript 12%
Updated 4 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago
Java
93%
Apache 2.0

QuestDB

Analytics · Databases

17,360

A high-performance, open-source time-series database built for financial market data, IoT telemetry, and real-time analytics, combining a zero-GC Java/C++ core with SIMD-accelerated SQL and a WAL-to-Parquet storage engine.

View details
91
Repo Health
86
Technical
67
Dependency
Built with
Java 93%
Updated 4 days ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,209

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
75
Repo Health
75
Technical
64
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 weeks ago
Rust
98%
Other

Zed

Code Editors · Collaboration · Developer Tools

90,979

High-performance, multiplayer code editor built in Rust by the creators of Atom and Tree-sitter, with native AI integration and real-time collaboration.

View details
94
Repo Health
88
Technical
72
Dependency
Built with
Rust 98%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers