Feature flagged out the text module

This commit is contained in:
Armin Ronacher 2021-01-24 09:26:56 +01:00
parent 18fff98d22
commit 16d1eea8fc
4 changed files with 11 additions and 4 deletions

View file

@ -13,7 +13,8 @@ readme = "README.md"
all-features = true
[features]
default = []
default = ["text"]
text = []
unicode = ["unicode-segmentation"]
[dev-dependencies]

View file

@ -7,7 +7,9 @@ doc:
@cargo doc --all-features
test:
@cargo test
@cargo test --all-features
@cargo test --no-default-features
format:
@rustup component add rustfmt 2> /dev/null

View file

@ -1,12 +1,13 @@
//! This crate implements diffing utilities. It attempts to provide an abstraction
//! interface over different types of diffing algorithms. It's based on the
//! the diff algorithm implementations of [pijul](https://pijul.org/).
//! ```rust
//! # #[cfg(feature = "text")] {
//! use similar::text::TextDiff;
//! # let old_text = "";
//! # let new_text = "";
//! let diff = TextDiff::from_chars("Hello World", "Hallo Welt");
//! # }
//! ```
//!
//! ## Functionality
@ -17,13 +18,15 @@
//! * [`text`]: This extends the general diffing functionality to text (and more
//! specifically line) based diff operations.
//!
//! ## Optional Features
//! ## Features
//!
//! The crate by default does not have any dependencies however for some use
//! cases it's useful to pull in extra functionality:
//! cases it's useful to pull in extra functionality. Likewise you can turn
//! off some functionality.
//!
//! * `unicode`: when this feature is enabled the text diffing functionality
//! gains the ability to diff on a grapheme instead of character level. This
//! is particularly useful when working with text containing emojis.
//! * `text`: this feature is enabled by default and enables the [`text`] module.
pub mod algorithms;
pub mod text;

View file

@ -47,6 +47,7 @@
//!
//! Because the [`TextDiff::grouped_ops`] method can isolate clusters of changes
//! this even works for very long files if paired with this method.
#![cfg(feature = "text")]
use std::borrow::Cow;
use std::fmt;
use std::io;