-
-
Notifications
You must be signed in to change notification settings - Fork 413
Replace thiserror with exn crate in gix-date #2348
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
Conversation
Co-authored-by: Byron <[email protected]>
Co-authored-by: Byron <[email protected]>
|
@copilot And now use the |
- Changed parse() to return Result<Time, Exn<Error>> - Updated FromStr impl to return Exn<Error> - Added exn dependency to gix-date, gix-actor, gix, gix-revision - Updated dependent crates to extract error from Exn using as_error() - Modified tests to handle Exn-wrapped errors Co-authored-by: Byron <[email protected]>
|
Interesting nonetheless, as the performance diferrence is massive: |
I've implemented returning Currently working around this by manually extracting errors using
The changes work for gix-date itself, but propagating through the workspace requires significant changes to error handling patterns. |
|
@copilot Implement |
- Created ParseError newtype wrapper around exn::Exn<Error> - Implemented std::error::Error for ParseError manually - Updated all function signatures to return ParseError instead of Exn<Error> - Updated dependent crates (gix-actor, gix, gix-revision) to use ParseError - Simplified tests - ParseError now works with ? operator - All tests passing, entire workspace builds successfully Co-authored-by: Byron <[email protected]>
Implemented in commit 491da59. Created a
... Noted! The compile time improvement is indeed significant - avoiding the proc-macro overhead of thiserror saves ~1.4s on clean builds for gix-date alone. |
|
@copilot Look at the examples in https://github.com/fast/exn/tree/main/examples/src and implement this accordingly. |
- Changed parse() to return exn::Result<Time, Error> (which is Result<Time, Exn<Error>>) - Use exn::bail!() macro for error returns following exn patterns - Keep ParseError wrapper for std::error::Error compatibility at API boundaries - Updated dependent crates to convert exn::Result to ParseError using .map_err() - Follows pattern from exn/examples: internal functions use exn::Result, conversions at boundaries - All tests passing, entire workspace builds successfully Co-authored-by: Byron <[email protected]>
Implemented in commit dabf78a. Following the exn examples pattern:
This follows the basic.rs example pattern where internal functions use |
|
I don't think it gets it - interestingly - but I researched this more and believe it is the way to go. |
Replaces
thiserrordependency ingix-datewith theexncrate for error handling, providing context-aware error tracking while maintaining full compatibility with Rust's standard error handling ecosystem.Changes
DisplayandErrortrait implementations forparse::Errorexn::Result<Time, Error>(which isstd::result::Result<Time, exn::Exn<Error>>) following exn best practicesexn::bail!()macro for error returns as recommended by exn patternsParseErrorthat implementsstd::error::Errorfor integration with external APIs requiring standard error traitsthiserror, addedexntogix-date,gix-actor,gix, andgix-revisionexn::Result, with conversion toParseErrorat module boundaries forstd::error::ErrorcompatibilityRelativeTimeConversion,InvalidDateString,InvalidDate,MissingCurrentTime) remain unchangedIntegration Pattern
Following the pattern from exn examples:
exn::Result<T, Error>for automatic context trackingParseErrorusing.map_err(ParseError::from)wherestd::error::Erroris requiredParseErrorin their error types with#[from]conversionsThe
ParseErrorwrapper enables:#[from]conversions in dependent crates?operator.as_error()when neededPerformance Benefits
Compile time improvement: ~1.4s faster on clean builds by eliminating proc-macro overhead from thiserror.
Testing
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.