-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
TraitDefinition::as_trait_constraint()
(#5541)
# Description ## Problem\* Part of work towards #4594 (comment), forgot an issue for this one. ## Summary\* ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
5 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
impl TraitDefinition { | ||
#[builtin(trait_def_as_trait_constraint)] | ||
fn as_trait_constraint(_self: Self) -> TraitConstraint {} | ||
} |
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_empty/trait_as_constraint/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "trait_as_constraint" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.31.0" | ||
|
||
[dependencies] |
9 changes: 9 additions & 0 deletions
9
test_programs/compile_success_empty/trait_as_constraint/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[test_as_constraint] | ||
trait Foo<T> {} | ||
|
||
comptime fn test_as_constraint(t: TraitDefinition) { | ||
let constraint = t.as_trait_constraint(); | ||
assert(constraint == constraint); | ||
} | ||
|
||
fn main() {} |