fix(docs): add missing type definitions in impl alias example #9499
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.
Summary
Fixed incomplete impl alias example in
aliases.adocby adding missing trait and impl definitions. The example previously referenced undefined types (Pow,Algebra,I32Algebra), making it confusing for readers who couldn't understand the code without external context.Type of change
Please check one:
Why is this change needed?
The impl alias example in
aliases.adocwas incomplete and misleading. It showed an impl alias referencingAnyAlgebraPow<i32, I32Algebra>, but neither thePowtrait,Algebratrait, norI32Algebraimpl were defined in the example. This made the code snippet non-functional and confusing for readers trying to understand impl aliases, as they couldn't see how the types relate or what the example actually demonstrates.What was the behavior or documentation before?
The example showed:airo
// Pow implementation for any algebra.
impl AnyAlgebraPow<A, impl AlgImpl: Algebra> of Pow { ... }
// Impl alias for Pow of i32.
impl Int32Pow = AnyAlgebraPow<i32, I32Algebra>;This referenced undefined types (
Pow,Algebra,I32Algebra) and used placeholder syntax ({ ... }), making it impossible to understand without looking up other documentation files.What is the behavior or documentation after?
The example now includes complete, self-contained definitions:o
trait Pow {
fn pow(base: T, exp: u32) -> T;
}
impl AnyAlgebraPow<T, impl AlgImpl: Algebra> of Pow {
fn pow(base: T, exp: u32) -> T {
// Implementation details.
base
}
}
trait Algebra {
fn identity() -> T;
}
impl I32Algebra of Algebra {
fn identity() -> i32 {
1
}
}
// Impl alias for Pow of i32.
impl Int32Pow = AnyAlgebraPow<i32, I32Algebra>;Readers can now understand the complete relationship between traits, impls, and impl aliases without needing to reference other documentation.
Related issue or discussion (if any)
Additional context
This aligns the example with the approach used in
impl-aliases.adoc, which provides complete, self-contained examples. The fix ensures consistency across documentation and improves the learning experience for developers new to Cairo's impl alias feature.