1- // Copyright 2016-2021 the Tectonic Project
1+ // Copyright 2016-2022 the Tectonic Project
22// Licensed under the MIT License.
33
44#![ deny( missing_docs) ]
@@ -349,7 +349,7 @@ impl<'a> CoreBridgeState<'a> {
349349 // `lipsum.ltd.tex` under the name `lipsum.ltd`.
350350
351351 for e in format. extensions ( ) {
352- let ext = format ! ( "{}.{}" , name , e ) ;
352+ let ext = format ! ( "{name }.{e}" ) ;
353353
354354 if let FileFormat :: Format = format {
355355 match io. input_open_format ( & ext, self . status ) {
@@ -714,11 +714,12 @@ pub struct SecuritySettings {
714714
715715/// Different high-level security stances that can be adopted when creating
716716/// [`SecuritySettings`].
717- #[ derive( Clone , Debug ) ]
717+ #[ derive( Clone , Debug , Default ) ]
718718pub enum SecurityStance {
719719 /// Ensure that all known-insecure features are disabled.
720720 ///
721721 /// Use this stance if you are processing untrusted input.
722+ #[ default]
722723 DisableInsecures ,
723724
724725 /// Request to allow the use of known-insecure features.
@@ -730,13 +731,6 @@ pub enum SecurityStance {
730731 MaybeAllowInsecures ,
731732}
732733
733- impl Default for SecurityStance {
734- fn default ( ) -> Self {
735- // Obvi, the default is secure!!!
736- SecurityStance :: DisableInsecures
737- }
738- }
739-
740734impl SecuritySettings {
741735 /// Create a new security configuration.
742736 ///
@@ -817,11 +811,7 @@ pub unsafe extern "C" fn ttbc_get_file_md5(
817811 let rpath = CStr :: from_ptr ( path) . to_string_lossy ( ) ;
818812 let rdest = slice:: from_raw_parts_mut ( digest, 16 ) ;
819813
820- if es. get_file_md5 ( rpath. as_ref ( ) , rdest) {
821- 1
822- } else {
823- 0
824- }
814+ libc:: c_int:: from ( es. get_file_md5 ( rpath. as_ref ( ) , rdest) )
825815}
826816
827817/// Calculate the MD5 digest of a block of binary data.
@@ -917,11 +907,7 @@ pub extern "C" fn ttbc_output_flush(
917907 es : & mut CoreBridgeState ,
918908 handle : * mut OutputHandle ,
919909) -> libc:: c_int {
920- if es. output_flush ( handle) {
921- 1
922- } else {
923- 0
924- }
910+ libc:: c_int:: from ( es. output_flush ( handle) )
925911}
926912
927913/// Close a Tectonic output file.
@@ -934,11 +920,7 @@ pub extern "C" fn ttbc_output_close(
934920 return 0 ; // This is/was the behavior of close_file() in C.
935921 }
936922
937- if es. output_close ( handle) {
938- 1
939- } else {
940- 0
941- }
923+ libc:: c_int:: from ( es. output_close ( handle) )
942924}
943925
944926/// Open a Tectonic file for input.
@@ -1137,11 +1119,7 @@ pub extern "C" fn ttbc_input_close(
11371119 return 0 ; // This is/was the behavior of close_file() in C.
11381120 }
11391121
1140- if es. input_close ( handle) {
1141- 1
1142- } else {
1143- 0
1144- }
1122+ libc:: c_int:: from ( es. input_close ( handle) )
11451123}
11461124
11471125/// A buffer for diagnostic messages. Rust code does not need to use this type.
@@ -1214,11 +1192,7 @@ pub unsafe extern "C" fn ttbc_shell_escape(
12141192 }
12151193 } ;
12161194
1217- if es. shell_escape ( & rcmd) {
1218- 1
1219- } else {
1220- 0
1221- }
1195+ libc:: c_int:: from ( es. shell_escape ( & rcmd) )
12221196}
12231197
12241198/// Different types of files that can be opened by TeX engines
0 commit comments