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

Add static values to resources #414

Merged
merged 7 commits into from
Aug 16, 2023
Merged

Add static values to resources #414

merged 7 commits into from
Aug 16, 2023

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Aug 16, 2023

  • Addition and retrieval of typed ops::Const to resources
  • simplify constant definitions with KnownConstType
  • move ConstUsize to prelude

@ss2165 ss2165 requested a review from aborgna-q August 16, 2023 11:49
@@ -126,6 +128,32 @@ trait TypeParametrised {
}
}

/// A constant value provided by a resource.
/// Must be an instance of a type available to the resource.
Copy link
Member Author

Choose a reason for hiding this comment

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

maybe this should be enforced as a check on creation?

Copy link
Member Author

Choose a reason for hiding this comment

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

never mind - requires the resource dependency system first

Copy link
Collaborator

@aborgna-q aborgna-q left a comment

Choose a reason for hiding this comment

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

LGTM

src/values.rs Outdated

/// Fixed implementation of [CustomConst::check_custom_type] that checks
/// against known correct type.
fn check_custom_type(&self, typ: &CustomType) -> Result<(), CustomCheckFailure> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wary of the same-name methods here,

  • On one side it opens up the possibility of buggy impls having different behaviour for <T as CustomConst>::check_custom_type and <T as KnownTypeConst>::check_custom_type.

  • Even with the same code, the compiler will ask you to disambiguate between the two at every callsite.

Perhaps it could be called check_known_type here, and still use it for the impl of CustomConst for ConstUsize ?

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea yes

@ss2165 ss2165 added this pull request to the merge queue Aug 16, 2023
Merged via the queue into main with commit 692cf6a Aug 16, 2023
6 checks passed
@ss2165 ss2165 deleted the new/resource-const branch August 16, 2023 15:04
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.

2 participants