Conversation
c8b2b3f to
8bfcf98
Compare
|
Just noticed that we should definitely turn formatting with |
|
Hmm, this is not a complete solution, see #902 (comment). Still I think
I'll rework this PR a bit. |
5b0f2de to
2d599f1
Compare
|
@jtmoon79 You may be interested in this CI failure https://github.com/chronotope/chrono/actions/runs/5169010209/jobs/9310999690?pr=1121 |
Ah nice, the bash error mode The In this case, I suggest re-running the failed CI job. |
2d599f1 to
22b2b78
Compare
|
Wrote up my thoughts in #1127. |
This PR is meant as an alternative to #902 and #614, for the problem in described in #575.
The problem is that if the format string is invalid, or contains a field that the type can not provide (such as time fields on a
NaiveDate), the display implementation returns an error.Some formattings macro's can correctly forward this error, such as
write!andwriteln!. Others, such asprintln!,format!andto_stringpanic instead.StrftimeItems::newreturn aResult. It will need some more work to detect a string with fields the type can not provide.fmt::Result<String>.Compared to #902 I believe this solution is better because:
String, instead of making it slightly harder to get aDelayedFormat.There are 5 new methods, all just a couple of lines of code:
DelayedFormat::try_to_stringNaiveDate::format_to_stringNaiveTime::format_to_stringNaiveDateTime::format_to_stringDateTime::format_to_stringMost of the effort in this PR is updating the surrounding documentation and examples, to make users more aware of the potential panic and the solutions.