@@ -643,9 +643,9 @@ impl Codec {
643643 /// assert!(codec.validate_placeholders(true).is_ok());
644644 /// ```
645645 pub fn validate_placeholders ( & self , strict : bool ) -> Result < ( ) , Error > {
646- use std:: collections:: HashMap ;
647646 use crate :: placeholder:: signature;
648647 use crate :: types:: Translation ;
648+ use std:: collections:: HashMap ;
649649
650650 // key -> lang -> Vec<signatures per form or single>
651651 let mut map: HashMap < String , HashMap < String , Vec < Vec < String > > > > = HashMap :: new ( ) ;
@@ -654,9 +654,7 @@ impl Codec {
654654 for entry in & res. entries {
655655 let sigs: Vec < Vec < String > > = match & entry. value {
656656 Translation :: Singular ( v) => vec ! [ signature( v) ] ,
657- Translation :: Plural ( p) => {
658- p. forms . values ( ) . map ( |v| signature ( v) ) . collect ( )
659- }
657+ Translation :: Plural ( p) => p. forms . values ( ) . map ( |v| signature ( v) ) . collect ( ) ,
660658 } ;
661659 map. entry ( entry. id . clone ( ) )
662660 . or_default ( )
@@ -714,9 +712,9 @@ impl Codec {
714712 ///
715713 /// Useful to warn in non-strict mode.
716714 pub fn collect_placeholder_issues ( & self ) -> Vec < String > {
717- use std:: collections:: HashMap ;
718715 use crate :: placeholder:: signature;
719716 use crate :: types:: Translation ;
717+ use std:: collections:: HashMap ;
720718
721719 let mut map: HashMap < String , HashMap < String , Vec < Vec < String > > > > = HashMap :: new ( ) ;
722720 for res in & self . resources {
@@ -1768,7 +1766,11 @@ mod tests {
17681766 let mut codec = Codec :: new ( ) ;
17691767 // English with %1$@, French with %1$s should match after normalization
17701768 codec. add_resource ( Resource {
1771- metadata : Metadata { language : "en" . into ( ) , domain : "d" . into ( ) , custom : HashMap :: new ( ) } ,
1769+ metadata : Metadata {
1770+ language : "en" . into ( ) ,
1771+ domain : "d" . into ( ) ,
1772+ custom : HashMap :: new ( ) ,
1773+ } ,
17721774 entries : vec ! [ Entry {
17731775 id: "greet" . into( ) ,
17741776 value: Translation :: Singular ( "Hello %1$@" . into( ) ) ,
@@ -1778,7 +1780,11 @@ mod tests {
17781780 } ] ,
17791781 } ) ;
17801782 codec. add_resource ( Resource {
1781- metadata : Metadata { language : "fr" . into ( ) , domain : "d" . into ( ) , custom : HashMap :: new ( ) } ,
1783+ metadata : Metadata {
1784+ language : "fr" . into ( ) ,
1785+ domain : "d" . into ( ) ,
1786+ custom : HashMap :: new ( ) ,
1787+ } ,
17821788 entries : vec ! [ Entry {
17831789 id: "greet" . into( ) ,
17841790 value: Translation :: Singular ( "Bonjour %1$s" . into( ) ) ,
@@ -1794,7 +1800,11 @@ mod tests {
17941800 fn test_validate_placeholders_mismatch ( ) {
17951801 let mut codec = Codec :: new ( ) ;
17961802 codec. add_resource ( Resource {
1797- metadata : Metadata { language : "en" . into ( ) , domain : "d" . into ( ) , custom : HashMap :: new ( ) } ,
1803+ metadata : Metadata {
1804+ language : "en" . into ( ) ,
1805+ domain : "d" . into ( ) ,
1806+ custom : HashMap :: new ( ) ,
1807+ } ,
17981808 entries : vec ! [ Entry {
17991809 id: "count" . into( ) ,
18001810 value: Translation :: Singular ( "%d files" . into( ) ) ,
@@ -1804,7 +1814,11 @@ mod tests {
18041814 } ] ,
18051815 } ) ;
18061816 codec. add_resource ( Resource {
1807- metadata : Metadata { language : "fr" . into ( ) , domain : "d" . into ( ) , custom : HashMap :: new ( ) } ,
1817+ metadata : Metadata {
1818+ language : "fr" . into ( ) ,
1819+ domain : "d" . into ( ) ,
1820+ custom : HashMap :: new ( ) ,
1821+ } ,
18081822 entries : vec ! [ Entry {
18091823 id: "count" . into( ) ,
18101824 value: Translation :: Singular ( "%s fichiers" . into( ) ) ,
@@ -1820,7 +1834,11 @@ mod tests {
18201834 fn test_collect_placeholder_issues_non_strict_ok ( ) {
18211835 let mut codec = Codec :: new ( ) ;
18221836 codec. add_resource ( Resource {
1823- metadata : Metadata { language : "en" . into ( ) , domain : "d" . into ( ) , custom : HashMap :: new ( ) } ,
1837+ metadata : Metadata {
1838+ language : "en" . into ( ) ,
1839+ domain : "d" . into ( ) ,
1840+ custom : HashMap :: new ( ) ,
1841+ } ,
18241842 entries : vec ! [ Entry {
18251843 id: "count" . into( ) ,
18261844 value: Translation :: Singular ( "%d files" . into( ) ) ,
@@ -1830,7 +1848,11 @@ mod tests {
18301848 } ] ,
18311849 } ) ;
18321850 codec. add_resource ( Resource {
1833- metadata : Metadata { language : "fr" . into ( ) , domain : "d" . into ( ) , custom : HashMap :: new ( ) } ,
1851+ metadata : Metadata {
1852+ language : "fr" . into ( ) ,
1853+ domain : "d" . into ( ) ,
1854+ custom : HashMap :: new ( ) ,
1855+ } ,
18341856 entries : vec ! [ Entry {
18351857 id: "count" . into( ) ,
18361858 value: Translation :: Singular ( "%s fichiers" . into( ) ) ,
@@ -1849,7 +1871,11 @@ mod tests {
18491871 fn test_normalize_placeholders_in_place ( ) {
18501872 let mut codec = Codec :: new ( ) ;
18511873 codec. add_resource ( Resource {
1852- metadata : Metadata { language : "en" . into ( ) , domain : "d" . into ( ) , custom : HashMap :: new ( ) } ,
1874+ metadata : Metadata {
1875+ language : "en" . into ( ) ,
1876+ domain : "d" . into ( ) ,
1877+ custom : HashMap :: new ( ) ,
1878+ } ,
18531879 entries : vec ! [ Entry {
18541880 id: "g" . into( ) ,
18551881 value: Translation :: Singular ( "Hello %@ and %1$@" . into( ) ) ,
@@ -1859,7 +1885,10 @@ mod tests {
18591885 } ] ,
18601886 } ) ;
18611887 codec. normalize_placeholders_in_place ( ) ;
1862- let v = match & codec. resources [ 0 ] . entries [ 0 ] . value { Translation :: Singular ( v) => v. clone ( ) , _ => String :: new ( ) } ;
1888+ let v = match & codec. resources [ 0 ] . entries [ 0 ] . value {
1889+ Translation :: Singular ( v) => v. clone ( ) ,
1890+ _ => String :: new ( ) ,
1891+ } ;
18631892 assert ! ( v. contains( "%s" ) ) ;
18641893 assert ! ( v. contains( "%1$s" ) ) ;
18651894 }
0 commit comments