Skip to content

Add std::chrono::time_point constructor overloads and tests - #50

Open
yalagadapavankumar wants to merge 7 commits into
rustfoundation:mainfrom
yalagadapavankumar:constructor-overloading
Open

yalagadapavankumar wants to merge 7 commits into
rustfoundation:mainfrom
yalagadapavankumar:constructor-overloading

Conversation

@yalagadapavankumar

@yalagadapavankumar yalagadapavankumar commented Oct 13, 2026 •

Copy link
Copy Markdown

Add C++ std::chrono::time_point constructors in Rust using overload! macro.

  • Default constructor: Creates time point at the clock's epoch.
  • Constructor from milliseconds: Creates time point from duration in milliseconds.
  • Converting constructor: Creates time point from another time point that uses seconds.
  1. Write Rust wrappers for that C++ type, for 3-5 different overloaded method names:
    • Create a new file named after your type in overloading-macros/cpp-overload-test/src/stdcpp
    • Wrap constructors first, writing tests to make sure the correct constructor is called
    • Explain any potential compatibility issues in a Limitations doc section
    • Explain usability issues in an Ergonomics doc section
    • Check that you have implemented all the overloads for each method name, or documented why you can't
    • Push your changes and wait for a review
  2. Add a separate example with some failing overloads
    • Create a new file named after your type in overloading-macros/cpp-overload-test/examples
    • Wrap accessor/modifier methods
    • Explain how they fail in an Incompatibilities doc section
    • Explain how the overload failures could be resolved in a Workarounds doc section
    • Optional: If there's a C++ feature with no equivalent in Rust, explain that in an Inexpressible Overloads doc section
    • Push your changes and wait for a review
  3. Update the overload macro compatibility table Markdown doc
    • If you haven't checked some kinds of overloads, put a ?in those squares
    • Push your changes and wait for a review

teor2345

This comment was marked as resolved.

Comment thread cpp-overload-test/src/stdcpp/time_point.rs Outdated
@yalagadapavankumar

This comment was marked as resolved.

@teor2345

This comment was marked as resolved.

@yalagadapavankumar

This comment was marked as resolved.

@yalagadapavankumar

This comment was marked as resolved.

@teor2345

Copy link
Copy Markdown
Collaborator

for the October round, and as far as I can see, they lead to the October channels.

this is the link representing as text which is not for October channel, which is exits in all 3 rust projects, for this project Extend Rust stdlib custom allocator support, they didn't provide zulip properly, so people believe this text is zulip channel for this project.

This is now fixed, and if people accidentally introduce themselves somewhere else, someone from the community will move their post to the right channel.

teor2345

This comment was marked as resolved.

@yalagadapavankumar

This comment was marked as resolved.

@yalagadapavankumar

This comment was marked as resolved.

@teor2345 teor2345 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, just need to tweak it to match the C++ overloads a bit more closely.

Comment thread cpp-overload-test/src/stdcpp/time_point.rs Outdated
Comment thread cpp-overload-test/src/stdcpp/time_point.rs Outdated
Comment thread cpp-overload-test/src/stdcpp/time_point.rs
@teor2345 teor2345 added the outreachy Tasks for outreachy applicants label Oct 27, 2026

@teor2345 teor2345 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good, let's move on to stage 2 of this task, using the instructions in the PR description.

Please create a new file with examples of failing overloads, the instructions for creating the stderr file are here:

# Or just do `cargo build --package cpp-overload-test --example NAME > cpp-overload-test/examples/NAME.stderr 2>&1`
# and delete the cargo Updating/Download*/Compiling logs.

//! ### Limitations
//!
//! C++ time points use clock and duration types.
//! This test uses fixed types instead of supporting all possible types.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a blocker for stage 2, but in your next update, please move this comment next to the declarations of those fixed types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

outreachy Tasks for outreachy applicants

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants