@@ -16,6 +16,12 @@ pub struct CEngine {
1616 compiler : Option < PathBuf > ,
1717}
1818
19+ impl Default for CEngine {
20+ fn default ( ) -> Self {
21+ Self :: new ( )
22+ }
23+ }
24+
1925impl CEngine {
2026 pub fn new ( ) -> Self {
2127 Self {
@@ -88,8 +94,8 @@ impl CEngine {
8894 let mut path = dir. join ( "run_c_binary" ) ;
8995 let suffix = std:: env:: consts:: EXE_SUFFIX ;
9096 if !suffix. is_empty ( ) {
91- if suffix. starts_with ( '.' ) {
92- path. set_extension ( & suffix [ 1 .. ] ) ;
97+ if let Some ( stripped ) = suffix. strip_prefix ( '.' ) {
98+ path. set_extension ( stripped ) ;
9399 } else {
94100 path = PathBuf :: from ( format ! ( "{}{}" , path. display( ) , suffix) ) ;
95101 }
@@ -928,7 +934,7 @@ fn is_item_snippet(code: &str) -> bool {
928934
929935 if trimmed. ends_with ( ';' ) {
930936 if trimmed. contains ( '(' ) && trimmed. contains ( ')' ) {
931- let before_paren = trimmed. splitn ( 2 , '(' ) . next ( ) . unwrap_or_default ( ) ;
937+ let before_paren = trimmed. split ( '(' ) . next ( ) . unwrap_or_default ( ) ;
932938 if before_paren. split_whitespace ( ) . count ( ) >= 2 {
933939 return true ;
934940 }
@@ -939,7 +945,7 @@ fn is_item_snippet(code: &str) -> bool {
939945 "auto" , "register" , "signed" , "unsigned" , "short" , "long" , "int" , "char" , "float" ,
940946 "double" , "_Bool" , "void" ,
941947 ] ;
942- if TYPE_PREFIXES . iter ( ) . any ( |kw| first_token == * kw ) {
948+ if TYPE_PREFIXES . contains ( & first_token) {
943949 return true ;
944950 }
945951 }
0 commit comments