Skip to content
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

perf(table): const TableState::new #1040

Merged
merged 1 commit into from Apr 22, 2024
Merged

perf(table): const TableState::new #1040

merged 1 commit into from Apr 22, 2024

Conversation

EdJoPaTo
Copy link
Member

Personally I think there should be either TableState::default() or TableState::new() but not both (#978). Here we have both, so at least allow for const fn new.

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.4%. Comparing base (1126478) to head (fde4848).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1040   +/-   ##
=====================================
  Coverage   89.4%   89.4%           
=====================================
  Files         61      61           
  Lines      15430   15433    +3     
=====================================
+ Hits       13799   13802    +3     
  Misses      1631    1631           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joshka
Copy link
Member

joshka commented Apr 22, 2024

Personally I think there should be either TableState::default() or TableState::new() but not both (#978). Here we have both, so at least allow for const fn new.

The rationale behind having both new and default is from https://rust-lang.github.io/api-guidelines/interoperability.html#c-common-traits

Note that it is common and expected for types to implement both Default and an empty new constructor. new is the constructor convention in Rust, and users expect it to exist, so if it is reasonable for the basic constructor to take no arguments, then it should, even if it is functionally identical to default.

@joshka joshka merged commit bf09234 into main Apr 22, 2024
33 checks passed
@joshka joshka deleted the table-state-const branch April 22, 2024 05:23
TadoTheMiner pushed a commit to TadoTheMiner/ratatui that referenced this pull request Apr 25, 2024
joshka pushed a commit to nowNick/ratatui that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants