-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue: Converting the API to return Result
s
#1469
Comments
For bonus points, make this more like a dependency tree? |
That would be cool to have, but it is more a dependency graph than a tree. |
Those are kind of the same thing IMO -- unless you expect there are a bunch of cycles in there? |
I'll add a 🌞 after items when I think they are ready to convert without deep dependencies. |
@Zomtir What would you like to work on next, if any? Then I'll stay clear. |
Unfortunately I am occupied for the next three weeks. I will rebase the checked_(add/sub)_days once I am home and have to take a break then. |
Thank you for everything until now 👍. |
Well... I lied. The succ/pred caught my eye and I could not resist. Uno mas: #1513 |
Please also all the Also, please have the Example Currently, the let duration_seconds = input_function();
let duration = Duration::try_seconds(duration_seconds).ok_or(Error::TimeRangeError(duration_seconds))?; Ideally however, it would work as follows: impl From<ChronoTimeRangeError> for Error {
fn from(ChronoTimeRangeError {value}: ChronoTimeRangeError) {
Error::TimeRangeError(value)
}
}
fn foo() -> Result<(), Error> {
let duration = Duration::try_seconds(input_function())?;
} |
Sorry, I was on mobile and just saw this part of your comment:
Interesting example! |
I will attempt |
Great! Honestly we are currently out of methods that are ready to convert. Converting the parsing methods depends on #1511, and the first preparations towards converting the methods that depend on the I'm not sure if we want to convert |
It does seem very weird to hide different errors behind For integers (unit-less scalar) the overall concept might be simpler than Appending |
So most methods on |
Partly related, but I noticed quite a few unchecked operations in TimeDelta:
The downcasting from i64 to i32 will wrap on overflow, which should be the same result as directly multiplying two i32. Both are standard behaviour of integers, but I wonder if this is acceptable for |
Do you mean |
My bad, The point I'm trying to make is that integer behaviour is not always applicable, so I don't know if Personally I'd find internal consistency preferable, e.g having
But in the greater context this is splitting hairs and we should focus on the bigger targets atm. Let me know if there is something do. |
Good point! |
A list to keep score. Not yet complete, and only lists the public API.
Currently at 61/153.
NaiveDate
NaiveDate::from_ymd
: 0.5: Converting the API to return Results (part 2):Mdf
type #1444NaiveDate::from_yo
: ConvertNaiveDate::{from_yo|from_isoywd}
to returnResult
#1460NaiveDate::from_isoywd
: ConvertNaiveDate::{from_yo|from_isoywd}
to returnResult
#1460NaiveDate::from_num_days_from_ce
: ConvertNaiveDate::from_num_days_from_ce
to returnResult
#1470NaiveDate::from_weekday_of_month
: ConvertNaiveDate::from_weekday_of_month
to returnResult
#1512NaiveDate::parse_from_str
NaiveDate::parse_and_remainder
NaiveDate::and_hms
: 0.5: Converting the API to return Results (part 1) #1410NaiveDate::and_hms_milli
: 0.5: Converting the API to return Results (part 1) #1410NaiveDate::and_hms_micro
: 0.5: Converting the API to return Results (part 1) #1410NaiveDate::and_hms_nano
: 0.5: Converting the API to return Results (part 1) #1410NaiveDate::succ
: ConvertNaiveDateTime::succ/pred
to returnResult
#1513NaiveDate::pred
: ConvertNaiveDateTime::succ/pred
to returnResult
#1513NaiveDate::checked_add_days
: ConvertNaiveDate/NaiveDateTime::checked_(add/sub)_days
to returnResult
#1475NaiveDate::checked_sub_days
: ConvertNaiveDate/NaiveDateTime::checked_(add/sub)_days
to returnResult
#1475NaiveDate::checked_add_months
: Convertchecked_add_months
,checked_sub_months
to returnResult
#1537NaiveDate::checked_sub_months
: Convertchecked_add_months
,checked_sub_months
to returnResult
#1537NaiveDate::checked_add_signed
: Convertchecked_(add|sub)_signed
to returnResult
#1514NaiveDate::checked_sub_signed
: Convertchecked_(add|sub)_signed
to returnResult
#1514NaiveDate::with_year
: 0.5: Convert API to returnResult
:Datelike::with_year
#1466NaiveDate::with_month
: Convertwith_month
andwith_day
to returnResult
#1509NaiveDate::with_day
: Convertwith_month
andwith_day
to returnResult
#1509NaiveDate::with_ordinal
: Convertwith_ordinal
to returnResult
#1531NaiveTime
NaiveTime::from_hms
: 0.5: Converting the API to return Results (part 1) #1410NaiveTime::from_hms_micro
: 0.5: Converting the API to return Results (part 1) #1410NaiveTime::from_hms_milli
: 0.5: Converting the API to return Results (part 1) #1410NaiveTime::from_hms_nano
: 0.5: Converting the API to return Results (part 1) #1410NaiveTime::from_num_seconds_from_midnight
: 0.5: Converting the API to return Results (part 1) #1410NaiveTime::parse_from_str
NaiveTime::parse_and_remainder
NaiveTime::with_hour
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveTime::with_minute
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveTime::with_second
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveTime::with_nanosecond
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveDateTime
NaiveDateTime::and_local_timezone
(toLocalResult
)NaiveDateTime::parse_and_remainder
NaiveDateTime::parse_from_str
NaiveDateTime::checked_add_days
: ConvertNaiveDate/NaiveDateTime::checked_(add/sub)_days
to returnResult
#1475NaiveDateTime::checked_sub_days
: ConvertNaiveDate/NaiveDateTime::checked_(add/sub)_days
to returnResult
#1475NaiveDateTime::checked_add_months
: Convertchecked_add_months
,checked_sub_months
to returnResult
#1537NaiveDateTime::checked_sub_months
: Convertchecked_add_months
,checked_sub_months
to returnResult
#1537NaiveDateTime::checked_add_signed
: Convertchecked_(add|sub)_signed
to returnResult
#1514NaiveDateTime::checked_sub_signed
: Convertchecked_(add|sub)_signed
to returnResult
#1514NaiveDateTime::checked_add_offset
: Convertchecked_(add|sub)_signed
to returnResult
#1514NaiveDateTime::checked_sub_offset
: Convertchecked_(add|sub)_signed
to returnResult
#1514NaiveDateTime::with_year
: 0.5: Convert API to returnResult
:Datelike::with_year
#1466NaiveDateTime::with_month
: Convertwith_month
andwith_day
to returnResult
#1509NaiveDateTime::with_day
: Convertwith_month
andwith_day
to returnResult
#1509NaiveDateTime::with_ordinal
: Convertwith_ordinal
to returnResult
#1531NaiveDateTime::with_hour
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveDateTime::with_minute
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveDateTime::with_second
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveDateTime::with_nanosecond
: Convert time-relatedwith_*
methods to returnResult
#1498NaiveWeek
NaiveWeek::first_day
(?)NaiveWeek::last_day
(?)NaiveWeek::days
(?)FixedOffset
FixedOffset::east
: ConvertFixedOffset::{east, west}
to returnResult
#1468FixedOffset::west
: ConvertFixedOffset::{east, west}
to returnResult
#1468TimeDelta
TimeDelta::new
: Convert methods onTimeDelta
to returnResult
#1538TimeDelta::milliseconds
: Convert methods onTimeDelta
to returnResult
#1538TimeDelta::num_microseconds
: Convert methods onTimeDelta
to returnResult
#1538TimeDelta::num_nanoseconds
: Convert methods onTimeDelta
to returnResult
#1538TimeDelta::checked_add
: ?TimeDelta::checked_sub
: ?TimeDelta::from_std
: Convert methods onTimeDelta
to returnResult
#1538TimeDelta::to_std
: Convert methods onTimeDelta
to returnResult
#1538DateTime
DateTime::checked_add_days
DateTime::checked_add_months
DateTime::checked_add_signed
DateTime::checked_sub_days
DateTime::checked_sub_months
DateTime::checked_sub_signed
DateTime::date_naive
(?)DateTime<Utc>::from_timestamp
: Convert timestamp methods onDateTime
to returnResult
s #1495DateTime<Utc>::from_timestamp_millis
: Convert timestamp methods onDateTime
to returnResult
s #1495DateTime<Utc>::from_timestamp_micros
: Convert timestamp methods onDateTime
to returnResult
s #1495DateTime::naive_local
(?)DateTime<FixedOffset>::parse_from_rfc2822
DateTime<FixedOffset>::parse_from_rfc3339
DateTime<FixedOffset>::parse_from_str
DateTime<FixedOffset>::parse_and_remainder
DateTime::timestamp_nanos
: Convert timestamp methods onDateTime
to returnResult
s #1495DateTime::to_rfc2822
DateTime::to_rfc3339
DateTime::with_timezone
DateTime::with_year
DateTime::with_month
DateTime::with_day
DateTime::with_ordinal
DateTime::with_time
DateTime::with_hour
DateTime::with_minute
DateTime::with_second
DateTime::with_nanosecond
: ConvertDateTime::with_nanosecond
to returnResult
#1520TimeZone
TimeZone::offset_from_local_datetime
TimeZone::offset_from_utc_datetime
TimeZone::from_local_datetime
TimeZone::from_utc_datetime
TimeZone::timestamp
TimeZone::timestamp_micros
TimeZone::timestamp_millis
TimeZone::timestamp_nanos
TimeZone::with_ymd_and_hms
LocalResult
LocalResult::single
LocalResult::earliest
LocalResult::latest
Parsed
Parsed::set_ampm
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_day
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_hour
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_hour12
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_isoweek
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_isoyear
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_isoyear_div_100
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_isoyear_mod_100
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_minute
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_month
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_nanosecond
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_offset
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_ordinal
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_second
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_timestamp
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_week_from_mon
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_week_from_sun
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_weekday
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_year
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_year_div_100
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::set_year_mod_100
: MergeParseError
withError
, convertParsed_set*
#1511Parsed::to_datetime
Parsed::to_datetime_with_timezone
Parsed::to_fixed_offset
Parsed::to_naive_date
Parsed::to_naive_datetime_with_offset
Parsed::to_naive_time
StrftimeItems
StrftimeItems::parse
StrftimeItems::parse_to_owned
Other
format::parse
format::parse_and_remainder
FromStr implementations
NaiveDate
NaiveTime
NaiveDateTime
DateTime<FixedOffset>
DateTime<Utc>
DateTime<Local>
FixedOffset
Weekday
Month
TryFrom implementations
TryFrom<u8> for Weekday
: 🌞TryFrom<u8> for Month
: 🌞TryFrom<SystemTime> for DateTime<Utc>
: ConvertTryFrom<SystemTime>
to our error type #1524TryFrom<SystemTime> for DateTime<Local>
TryFrom<DateTime<Tz>> for SystemTime
: ConvertTryFrom<SystemTime>
to our error type #1524From<DateTime<Utc>> for DateTime<Local>
From<DateTime<FixedOffset>> for DateTime<Local>
The text was updated successfully, but these errors were encountered: