Skip to content

Commit 7e87927

Browse files
djcpitdicker
authored andcommitted
Revert to default style
1 parent d99e9a6 commit 7e87927

File tree

11 files changed

+528
-148
lines changed

11 files changed

+528
-148
lines changed

chrono-tz-build/src/lib.rs

+62-13
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ fn strip_comments(mut line: String) -> String {
3232
// to this zone, as a string representation of a static slice.
3333
fn format_rest(rest: Vec<(i64, FixedTimespan)>) -> String {
3434
let mut ret = "&[\n".to_string();
35-
for (start, FixedTimespan { utc_offset, dst_offset, name }) in rest {
35+
for (
36+
start,
37+
FixedTimespan {
38+
utc_offset,
39+
dst_offset,
40+
name,
41+
},
42+
) in rest
43+
{
3644
ret.push_str(&format!(
3745
" ({start}, FixedTimespan {{ \
3846
utc_offset: {utc}, dst_offset: {dst}, name: \"{name}\" \
@@ -53,7 +61,12 @@ fn format_rest(rest: Vec<(i64, FixedTimespan)>) -> String {
5361
fn convert_bad_chars(name: &str) -> String {
5462
let name = name.replace('/', "__").replace('+', "Plus");
5563
if let Some(pos) = name.find('-') {
56-
if name[pos + 1..].chars().next().map(char::is_numeric).unwrap_or(false) {
64+
if name[pos + 1..]
65+
.chars()
66+
.next()
67+
.map(char::is_numeric)
68+
.unwrap_or(false)
69+
{
5770
name.replace('-', "Minus")
5871
} else {
5972
name.replace('-', "")
@@ -67,8 +80,15 @@ fn convert_bad_chars(name: &str) -> String {
6780
// database. The `Wrap` wrapper in the `timezone_impl` module then implements
6881
// TimeZone for any contained struct that implements `Timespans`.
6982
fn write_timezone_file(timezone_file: &mut File, table: &Table) -> io::Result<()> {
70-
let zones = table.zonesets.keys().chain(table.links.keys()).collect::<BTreeSet<_>>();
71-
writeln!(timezone_file, "use core::fmt::{{self, Debug, Display, Formatter}};",)?;
83+
let zones = table
84+
.zonesets
85+
.keys()
86+
.chain(table.links.keys())
87+
.collect::<BTreeSet<_>>();
88+
writeln!(
89+
timezone_file,
90+
"use core::fmt::{{self, Debug, Display, Formatter}};",
91+
)?;
7292
writeln!(timezone_file, "use core::str::FromStr;\n",)?;
7393
writeln!(
7494
timezone_file,
@@ -83,7 +103,10 @@ fn write_timezone_file(timezone_file: &mut File, table: &Table) -> io::Result<()
83103
/// for details."
84104
)?;
85105
writeln!(timezone_file, "#[derive(Clone, Copy, PartialEq, Eq, Hash)]")?;
86-
writeln!(timezone_file, r#"#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]"#)?;
106+
writeln!(
107+
timezone_file,
108+
r#"#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]"#
109+
)?;
87110
writeln!(timezone_file, "pub enum Tz {{")?;
88111
for zone in &zones {
89112
let zone_name = convert_bad_chars(zone);
@@ -100,20 +123,29 @@ fn write_timezone_file(timezone_file: &mut File, table: &Table) -> io::Result<()
100123
for zone in &zones {
101124
map.entry(zone, &format!("Tz::{}", convert_bad_chars(zone)));
102125
}
103-
writeln!(timezone_file, "static TIMEZONES: ::phf::Map<&'static str, Tz> = \n{};", map.build())?;
126+
writeln!(
127+
timezone_file,
128+
"static TIMEZONES: ::phf::Map<&'static str, Tz> = \n{};",
129+
map.build()
130+
)?;
104131

105132
#[cfg(feature = "case-insensitive")]
106133
{
107134
writeln!(timezone_file, "use uncased::UncasedStr;\n",)?;
108135
let mut map = phf_codegen::Map::new();
109136
for zone in &zones {
110-
map.entry(uncased::UncasedStr::new(zone), &format!("Tz::{}", convert_bad_chars(zone)));
137+
map.entry(
138+
uncased::UncasedStr::new(zone),
139+
&format!("Tz::{}", convert_bad_chars(zone)),
140+
);
111141
}
112142
writeln!(
113143
timezone_file,
114144
"static TIMEZONES_UNCASED: ::phf::Map<&'static uncased::UncasedStr, Tz> = \n{};",
115145
// FIXME(petrosagg): remove this once rust-phf/rust-phf#232 is released
116-
map.build().to_string().replace("::std::mem::transmute", "::core::mem::transmute")
146+
map.build()
147+
.to_string()
148+
.replace("::std::mem::transmute", "::core::mem::transmute")
117149
)?;
118150
}
119151

@@ -242,7 +274,11 @@ pub static TZ_VARIANTS: [Tz; {num}] = [
242274
num = zones.len()
243275
)?;
244276
for zone in &zones {
245-
writeln!(timezone_file, " Tz::{zone},", zone = convert_bad_chars(zone))?;
277+
writeln!(
278+
timezone_file,
279+
" Tz::{zone},",
280+
zone = convert_bad_chars(zone)
281+
)?;
246282
}
247283
write!(timezone_file, "];")?;
248284
Ok(())
@@ -252,7 +288,10 @@ pub static TZ_VARIANTS: [Tz; {num}] = [
252288
// instead of having to use chrono_tz::timezones::Europe__London
253289
fn write_directory_file(directory_file: &mut File, table: &Table, version: &str) -> io::Result<()> {
254290
// expose the underlying IANA TZDB version
255-
writeln!(directory_file, "pub const IANA_TZDB_VERSION : &str = \"{version}\";\n")?;
291+
writeln!(
292+
directory_file,
293+
"pub const IANA_TZDB_VERSION : &str = \"{version}\";\n"
294+
)?;
256295
// add the `loose' zone definitions first
257296
writeln!(directory_file, "use crate::timezones::Tz;\n")?;
258297
let zones = table
@@ -263,7 +302,11 @@ fn write_directory_file(directory_file: &mut File, table: &Table, version: &str)
263302
.collect::<BTreeSet<_>>();
264303
for zone in zones {
265304
let zone = convert_bad_chars(zone);
266-
writeln!(directory_file, "pub const {name} : Tz = Tz::{name};", name = zone)?;
305+
writeln!(
306+
directory_file,
307+
"pub const {name} : Tz = Tz::{name};",
308+
name = zone
309+
)?;
267310
}
268311
writeln!(directory_file)?;
269312

@@ -279,7 +322,11 @@ fn write_directory_file(directory_file: &mut File, table: &Table, version: &str)
279322
match child {
280323
Child::Submodule(name) => {
281324
let submodule_name = convert_bad_chars(name);
282-
writeln!(directory_file, " pub mod {name} {{", name = submodule_name)?;
325+
writeln!(
326+
directory_file,
327+
" pub mod {name} {{",
328+
name = submodule_name
329+
)?;
283330
writeln!(directory_file, " use crate::timezones::Tz;\n",)?;
284331
let full_name = entry.name.to_string() + "/" + name;
285332
for entry in table.structure() {
@@ -428,7 +475,9 @@ mod filter {
428475
}
429476

430477
// Actually do the filtering.
431-
table.links.retain(|k, v| keep.contains(k) || keep.contains(v));
478+
table
479+
.links
480+
.retain(|k, v| keep.contains(k) || keep.contains(v));
432481

433482
table
434483
.zonesets

chrono-tz/src/binary_search.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ fn test_binary_search() {
2727
assert_eq!(binary_search(30, 50, |x| x.cmp(&42)), Ok(42));
2828
assert_eq!(binary_search(300, 500, |x| x.cmp(&42)), Err(300));
2929
assert_eq!(
30-
binary_search(0, 500, |x| if x < 42 { Ordering::Less } else { Ordering::Greater }),
30+
binary_search(0, 500, |x| if x < 42 {
31+
Ordering::Less
32+
} else {
33+
Ordering::Greater
34+
}),
3135
Err(42)
3236
);
3337
}

0 commit comments

Comments
 (0)