File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed
Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change 11use std:: collections:: BTreeMap ;
22
33use rss:: {
4- ChannelBuilder , ItemBuilder ,
54 extension:: { Extension , ExtensionBuilder } ,
5+ ChannelBuilder , ItemBuilder ,
66} ;
77use time:: format_description:: well_known:: { Rfc2822 , Rfc3339 } ;
88
@@ -14,21 +14,13 @@ impl From<SsufidPost> for rss::Item {
1414 fn from ( post : SsufidPost ) -> Self {
1515 let mut builder = ItemBuilder :: default ( ) ;
1616
17- let description = {
18- let truncate_idx = post
19- . content
20- . char_indices ( )
21- . nth ( 50 )
22- . map_or ( post. content . len ( ) , |( i, _) | i) ;
23- if truncate_idx < post. content . len ( ) {
24- let mut truncated = post. content . clone ( ) ;
25- truncated. truncate ( truncate_idx) ;
26- truncated. push_str ( "..." ) ;
27- truncated
28- } else {
29- post. content . clone ( )
30- }
31- } ;
17+ let description = post
18+ . content
19+ . char_indices ( )
20+ . nth ( 50 )
21+ . map_or_else ( || post. content . clone ( ) , |( i, _) | {
22+ format ! ( "{}..." , & post. content[ ..i] )
23+ } ) ;
3224
3325 builder
3426 . title ( post. title )
You can’t perform that action at this time.
0 commit comments