Skip to content

Commit 33c86b7

Browse files
hovinenbcopybara-github
authored andcommitted
Rename edit_distance::Configuration to edit_distance::Mode.
The name "configuration" (generally referring to a bunch of related settings) does not seem to reflect what this enum actually does. Rather "mode" (a single setting) seems more appropriate. The new name is also far more succinct. PiperOrigin-RevId: 533471296
1 parent 8d70e80 commit 33c86b7

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

googletest/src/matcher_support/edit_distance.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::ops::Index;
2121
pub(crate) fn edit_list<T: Distance + Copy>(
2222
left: impl IntoIterator<Item = T>,
2323
right: impl IntoIterator<Item = T>,
24-
configuration: Configuration,
24+
mode: Mode,
2525
) -> Vec<Edit<T>> {
2626
let left: Vec<_> = left.into_iter().collect();
2727
let right: Vec<_> = right.into_iter().collect();
@@ -38,18 +38,18 @@ pub(crate) fn edit_list<T: Distance + Copy>(
3838
last_edit: Edit::ExtraLeft { left: left[0] },
3939
});
4040

41-
// The configuration changes how the beginning and the end of left is consumed.
41+
// The mode changes how the beginning and the end of left is consumed.
4242
// EndsWith and Contains makes the consumption of elements of left before the
4343
// first element of right is consumed free. In the implementation, this leads
4444
// to table[(_, 0)] == 0.
4545
// StartsWith and Contains makes the consumption of character of left after the
4646
// last element of right is consumed free. In the implementation, this leads to
4747
// ExtraLeft being free when computing table[(_, right.len())].
48-
let (free_start, free_end) = match configuration {
49-
Configuration::FullMatch => (false, false),
50-
Configuration::StartsWith => (false, true),
51-
Configuration::EndsWith => (true, false),
52-
Configuration::Contains => (true, true),
48+
let (free_start, free_end) = match mode {
49+
Mode::FullMatch => (false, false),
50+
Mode::StartsWith => (false, true),
51+
Mode::EndsWith => (true, false),
52+
Mode::Contains => (true, true),
5353
};
5454

5555
for idx in 1..(left.len() + 1) {
@@ -106,7 +106,7 @@ pub(crate) fn edit_list<T: Distance + Copy>(
106106

107107
/// Controls how `right` should match `left`.
108108
#[allow(dead_code)]
109-
pub(crate) enum Configuration {
109+
pub(crate) enum Mode {
110110
/// `right` is fully matching `left`
111111
FullMatch,
112112
/// `right` should match the beginning of `left`
@@ -157,7 +157,7 @@ impl Distance for &str {
157157
if left == right {
158158
return 0.0;
159159
}
160-
let edits: f64 = edit_list(left.chars(), right.chars(), Configuration::FullMatch)
160+
let edits: f64 = edit_list(left.chars(), right.chars(), Mode::FullMatch)
161161
.into_iter()
162162
.map(|edit| match edit {
163163
Edit::Both { distance, .. } => distance,
@@ -211,7 +211,7 @@ mod tests {
211211
use crate::elements_are;
212212
use crate::{matcher::Matcher, matchers::predicate, verify_that, Result};
213213
use indoc::indoc;
214-
use Configuration::*;
214+
use Mode::*;
215215

216216
fn is_both<E: PartialEq + Debug>(
217217
l_expected: E,

googletest/src/matchers/eq_matcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub(super) fn create_diff(expected_debug: &str, actual_debug: &str, description:
112112
let edit_list = edit_distance::edit_list(
113113
actual_debug.lines(),
114114
expected_debug.lines(),
115-
edit_distance::Configuration::FullMatch,
115+
edit_distance::Mode::FullMatch,
116116
);
117117

118118
if edit_list.is_empty() {

0 commit comments

Comments
 (0)