review(p9-fb-10-task1): drop unused char_len + harden pop invariant test + doc new()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-03 09:23:29 +00:00
parent dfec781f0a
commit 7b0beed280

View File

@@ -91,6 +91,7 @@ pub struct InputBuffer {
}
impl InputBuffer {
/// Create an empty buffer.
pub fn new() -> Self {
Self::default()
}
@@ -142,12 +143,6 @@ impl InputBuffer {
pub fn is_empty(&self) -> bool {
self.content.is_empty()
}
/// Length of `content` in chars (NOT display columns). Use
/// `cursor_col()` for column-aware layout.
pub fn char_len(&self) -> usize {
self.content.chars().count()
}
}
#[cfg(test)]
@@ -268,6 +263,8 @@ mod tests {
assert_eq!(popped, Some('트'));
assert_eq!(b.cursor_col(), 4);
assert_eq!(b.as_str(), "러스");
// Invariant must still hold after pop, not just after push.
assert_eq!(b.cursor_col(), display_width(b.as_str()));
b.push_char('a');
assert_eq!(b.cursor_col(), 5);
assert_eq!(b.as_str(), "러스a");