From 3e65272d7bd4b91851c3a361dff125f098dbcb32 Mon Sep 17 00:00:00 2001 From: Zihang Ye Date: Thu, 8 Aug 2024 17:47:32 +0800 Subject: [PATCH] fix: format & info (#40) --- crypto/sha1.mbt | 11 ++++++----- json5/json5.mbti | 4 +--- time/duration.mbt | 6 +++--- time/period.mbt | 7 ++++--- time/plain_date.mbt | 6 +++--- time/plain_date_time.mbt | 4 +++- time/plain_time.mbt | 6 +++--- uuid/uuid.mbt | 6 +++--- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/crypto/sha1.mbt b/crypto/sha1.mbt index 0cde33a..3540c24 100644 --- a/crypto/sha1.mbt +++ b/crypto/sha1.mbt @@ -34,11 +34,12 @@ pub fn sha1(input : Bytes) -> Bytes { let words = FixedArray::make(80, 0) for i = 0; i < 16; i = i + 1 { let slice_start = chunk * bytes_per_chunk + i * 4 - words[i] = bytes[slice_start].to_int().lsl(24).lor( - bytes[slice_start + 1].to_int().lsl(16), - ).lor(bytes[slice_start + 2].to_int().lsl(8)).lor( - bytes[slice_start + 3].to_int(), - ) + words[i] = bytes[slice_start] + .to_int() + .lsl(24) + .lor(bytes[slice_start + 1].to_int().lsl(16)) + .lor(bytes[slice_start + 2].to_int().lsl(8)) + .lor(bytes[slice_start + 3].to_int()) } for i = 16; i < 80; i = i + 1 { words[i] = rotate_left( diff --git a/json5/json5.mbti b/json5/json5.mbti index 0fc2104..6a15037 100644 --- a/json5/json5.mbti +++ b/json5/json5.mbti @@ -1,9 +1,7 @@ package moonbitlang/x/json5 -alias @moonbitlang/core/json as @json - // Values -fn parse(String) -> @json.JsonValue!ParseError +fn parse(String) -> Json!ParseError // Types and methods type ParseError diff --git a/time/duration.mbt b/time/duration.mbt index 90d7123..857ed4d 100644 --- a/time/duration.mbt +++ b/time/duration.mbt @@ -126,9 +126,9 @@ pub fn to_string(self : Duration) -> String { buf.write_string(secs.to_string()) if nanos > 0L { buf.write_char('.') - let nanos_str = (nanos + nanoseconds_per_second).to_string().substring( - start=1, - ) + let nanos_str = (nanos + nanoseconds_per_second) + .to_string() + .substring(start=1) buf.write_string(remove_suffix_zero(nanos_str)) } buf.write_char('S') diff --git a/time/period.mbt b/time/period.mbt index 3b2905e..9ff7eee 100644 --- a/time/period.mbt +++ b/time/period.mbt @@ -148,9 +148,10 @@ pub fn add_period(self : Period, other : Period) -> Period!Error { if other.is_zero() { return self } - self.add_years!(other.years()).add_months!(other.months()).add_days!( - other.days(), - ) + self + .add_years!(other.years()) + .add_months!(other.months()) + .add_days!(other.days()) } pub fn op_add(self : Period, other : Period) -> Period!Error { diff --git a/time/plain_date.mbt b/time/plain_date.mbt index 9020ce1..26325f6 100644 --- a/time/plain_date.mbt +++ b/time/plain_date.mbt @@ -313,9 +313,9 @@ pub fn add_days(self : PlainDate, days : Int64) -> PlainDate!Error { /// Adds a period to this date, and returns a new date. pub fn add_period(self : PlainDate, period : Period) -> PlainDate!Error { let mut d = self - d = d.add_months!(period.to_total_months()).add_days!( - period.days().to_int64(), - ) + d = d + .add_months!(period.to_total_months()) + .add_days!(period.days().to_int64()) d } diff --git a/time/plain_date_time.mbt b/time/plain_date_time.mbt index b59a898..a7afd28 100644 --- a/time/plain_date_time.mbt +++ b/time/plain_date_time.mbt @@ -55,7 +55,9 @@ pub fn PlainDateTime::from_unix_second( /// Converts this datetime to the elapsed seconds since the unix epoch. pub fn to_unix_second(self : PlainDateTime) -> Int64 { - self.date.to_unix_day() * seconds_per_day + self.time.second_of_day().to_int64() + self.date.to_unix_day() * seconds_per_day + self.time + .second_of_day() + .to_int64() } /// Creates a PlainTime from a string, like '2008-08-08T20:00:00'. diff --git a/time/plain_time.mbt b/time/plain_time.mbt index dc963ac..5c9c3d6 100644 --- a/time/plain_time.mbt +++ b/time/plain_time.mbt @@ -69,9 +69,9 @@ pub fn PlainTime::to_string(self : PlainTime) -> String { buf.write_string(add_prefix_zero(self.second.to_string(), 2)) if self.nanosecond > 0 { buf.write_char('.') - let nanos_str = (self.nanosecond.to_int64() + nanoseconds_per_second).to_string().substring( - start=1, - ) + let nanos_str = (self.nanosecond.to_int64() + nanoseconds_per_second) + .to_string() + .substring(start=1) buf.write_string(remove_suffix_zero(nanos_str)) } buf.to_string() diff --git a/uuid/uuid.mbt b/uuid/uuid.mbt index def00c6..99e3876 100644 --- a/uuid/uuid.mbt +++ b/uuid/uuid.mbt @@ -149,9 +149,9 @@ pub fn from_hex(hex : String) -> UUID!Error { } } -let hex_table : Array[Int] = "0123456789abcdef".to_array().map( - fn { c => c.to_int() }, -) +let hex_table : Array[Int] = "0123456789abcdef" + .to_array() + .map(fn { c => c.to_int() }) let dash : Int = '-'.to_int()