Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit65fced1

Browse files
committed
Add documentation
1 parent29c8e7f commit65fced1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎src/formatter/mod.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,17 @@ impl<'a> DisplayList<'a> {
218218
}else{
219219
false
220220
};
221+
// Specifies that it will end on the next character, so it will return
222+
// until the next one to the final condition.
221223
letmut ended =false;
222224
let range = text
223225
.char_indices()
224-
.chain(once((text.len(),'\0')))
225226
.skip(left)
227+
// Complete char iterator with final character
228+
.chain(once((text.len(),'\0')))
229+
// Take until the next one to the final condition
226230
.take_while(|(_, ch)|{
231+
// Fast return to iterate over final byte position
227232
if ended{
228233
returnfalse;
229234
}
@@ -236,6 +241,7 @@ impl<'a> DisplayList<'a> {
236241
}
237242
true
238243
})
244+
// Reduce to start and end byte position
239245
.fold((None,0), |acc,(i, _)|{
240246
if acc.0.is_some(){
241247
(acc.0, i)
@@ -244,6 +250,7 @@ impl<'a> DisplayList<'a> {
244250
}
245251
});
246252

253+
// Format text with margins
247254
text[range.0.expect("One character at line")..range.1].fmt(f)?;
248255

249256
if cut_right{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp