mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-03 01:16:14 +03:00
@@ -25,7 +25,10 @@ pub(crate) fn remove_markdown(markdown: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(p) = out.rfind(|c| c != '\n') {
|
||||
if let Some(mut p) = out.rfind(|c| c != '\n') {
|
||||
while !out.is_char_boundary(p + 1) {
|
||||
p += 1;
|
||||
}
|
||||
out.drain(p + 1..);
|
||||
}
|
||||
|
||||
@@ -153,4 +156,10 @@ fn generic_where<T>(x: T) -> T
|
||||
|
||||
For more information on the various types of functions and how they're used, consult the Rust book or the Reference."#]].assert_eq(&res);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_char_boundary() {
|
||||
expect!["a┘"].assert_eq(&remove_markdown("```text\na┘\n```"));
|
||||
expect!["وقار"].assert_eq(&remove_markdown("```\nوقار\n```\n"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user