@@ -1801,42 +1801,25 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1801
1801
}
1802
1802
}
1803
1803
1804
- #[ derive( Debug ) ]
1805
- struct Settings < ' a > {
1804
+ fn settings ( root_path : & str , suffix : & str ) -> String {
1806
1805
// (id, explanation, default value)
1807
- settings : Vec < ( & ' static str , & ' static str , bool ) > ,
1808
- root_path : & ' a str ,
1809
- suffix : & ' a str ,
1810
- }
1811
-
1812
- impl < ' a > Settings < ' a > {
1813
- pub fn new ( root_path : & ' a str , suffix : & ' a str ) -> Settings < ' a > {
1814
- Settings {
1815
- settings : vec ! [
1816
- ( "item-declarations" , "Auto-hide item declarations." , true ) ,
1817
- ( "item-attributes" , "Auto-hide item attributes." , true ) ,
1818
- ( "trait-implementations" , "Auto-hide trait implementations documentation" ,
1819
- true ) ,
1820
- ( "method-docs" , "Auto-hide item methods' documentation" , false ) ,
1821
- ( "go-to-only-result" , "Directly go to item in search if there is only one result" ,
1822
- false ) ,
1823
- ( "line-numbers" , "Show line numbers on code examples" , false ) ,
1824
- ] ,
1825
- root_path,
1826
- suffix,
1827
- }
1828
- }
1829
- }
1830
-
1831
- impl < ' a > fmt:: Display for Settings < ' a > {
1832
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1833
- write ! ( f,
1806
+ let settings = [
1807
+ ( "item-declarations" , "Auto-hide item declarations." , true ) ,
1808
+ ( "item-attributes" , "Auto-hide item attributes." , true ) ,
1809
+ ( "trait-implementations" , "Auto-hide trait implementations documentation" ,
1810
+ true ) ,
1811
+ ( "method-docs" , "Auto-hide item methods' documentation" , false ) ,
1812
+ ( "go-to-only-result" , "Directly go to item in search if there is only one result" ,
1813
+ false ) ,
1814
+ ( "line-numbers" , "Show line numbers on code examples" , false ) ,
1815
+ ] ;
1816
+ format ! (
1834
1817
"<h1 class='fqn'>\
1835
1818
<span class='in-band'>Rustdoc settings</span>\
1836
1819
</h1>\
1837
1820
<div class='settings'>{}</div>\
1838
1821
<script src='{}settings{}.js'></script>",
1839
- self . settings. iter( )
1822
+ settings. iter( )
1840
1823
. map( |( id, text, enabled) | {
1841
1824
format!( "<div class='setting-line'>\
1842
1825
<label class='toggle'>\
@@ -1847,9 +1830,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1847
1830
</div>", id, if * enabled { " checked" } else { "" } , text)
1848
1831
} )
1849
1832
. collect:: <String >( ) ,
1850
- self . root_path,
1851
- self . suffix)
1852
- }
1833
+ root_path,
1834
+ suffix)
1853
1835
}
1854
1836
1855
1837
impl Context {
@@ -1924,8 +1906,6 @@ impl Context {
1924
1906
self . shared . fs . write ( & final_file, v. as_bytes ( ) ) ?;
1925
1907
1926
1908
// Generating settings page.
1927
- let settings = Settings :: new ( self . shared . static_root_path . as_deref ( ) . unwrap_or ( "./" ) ,
1928
- & self . shared . resource_suffix ) ;
1929
1909
page. title = "Rustdoc settings" ;
1930
1910
page. description = "Settings of Rustdoc" ;
1931
1911
page. root_path = "./" ;
@@ -1935,7 +1915,10 @@ impl Context {
1935
1915
themes. push ( PathBuf :: from ( "settings.css" ) ) ;
1936
1916
let v = layout:: render (
1937
1917
& self . shared . layout ,
1938
- & page, sidebar, |buf : & mut Buffer | buf. from_display ( settings) ,
1918
+ & page, sidebar, settings (
1919
+ self . shared . static_root_path . as_deref ( ) . unwrap_or ( "./" ) ,
1920
+ & self . shared . resource_suffix
1921
+ ) ,
1939
1922
& themes) ;
1940
1923
self . shared . fs . write ( & settings_file, v. as_bytes ( ) ) ?;
1941
1924
0 commit comments