Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The layout can often contain things that are already known at compile time which speeds up things on runtime. Especially as render is called a lot.
With 0.26.0 the
Rect::contains
method is now accepting a Position. Whilecontains
isconst
,Position::new
is not which triggered the creation of this PR. I switched toPosition { x, y }
, but the compiler should be able to do the same inconst
with::new()
.I added the lint to the layout module, but I don't really know what other plans of this project are in regard to configuring lints. I could also just remove the lint there, but mistakes like the current one will happen again as the code uses a lot of
const
already. Do you have other thoughts on how to configure the lints best?I observed the missing_const_for_fn clippy lint in other areas of the library too, but it's mostly pointless there. Some Widgets and WidgetStates could get
::new()
implementations which areconst
which would also allow for optimizations there.Personally I also think that more
clippy::pedantic
andclippy::nursery
lints could keep the code quality of ratatui consistent. Like in the current case many things are alreadyconst
, but they are forgotten in other places as no lints are ensuring that.