dependency graph

This commit is contained in:
AF 2023-07-31 20:41:27 +00:00
parent e9cf323ca2
commit 28f28b8298
3 changed files with 35 additions and 6 deletions

View File

@ -1,4 +1,4 @@
Make `test_covariance` compile by making `BoolStream<'a>` covariant `'a`.
Make `test_covariance` compile by making `BoolStream<'a>` covariant `'a`. Restrictions:
- Can only change implementation details of `BoolStream` and its methods and add extra items outside of what's given, i.e. no signature/test change.
- Changed version must behave the same way.
```rust

View File

@ -1,13 +1,14 @@
Make this compile.
Make this compile with the following restrictions:
- `A1` doesn't know about/depend on `A2`.
- `A2` doesn't know about/depend on `A1`.
- `A1` doesn't know about/depend on `A`.
- `A2` doesn't know about/depend on `A`.
- Some types are `A1` but not `A2`.
- Some types are `A2` but not `A1`.
- **Some types are `A1` but not `A2`.**
- **Some types are `A2` but not `A1`.**
- Some types are `A` but not `A2`.
- Some types are `A` but not `A1`.
- Can't edit definitions of `A`, `test`, `tes1`, `test2`; can only add code outside of those items.
- **Can't edit definitions of `A`, `test`, `tes1`, `test2`; can only add code outside of those items.**
```rust
trait A {
fn a_ref(&self) -> u64;
@ -72,3 +73,31 @@ fn test2(x: impl A2) {
# fn ap_move(t: Self::T) -> Self::T { t.a2_move() }
# }
```
You may assume that `A`, `A1`, `A2` can be in separate crates with a dependency graph equivalent to this:
```rust
# mod __ {
mod a1 {
pub trait A1 { /* ... */ }
/* ... */
}
mod a2 {
pub trait A2 { /* ... */ }
/* ... */
}
mod a {
use super::{a1, a2};
pub trait A { /* ... */ }
/* ... */
}
mod external {
use super::{a::A, a1::A1, a2::A2};
fn test(x: impl A) { /* ... */ }
fn test1(x: impl A1) { /* ... */ }
fn test2(x: impl A2) { /* ... */ }
}
# }
```

View File

@ -5,7 +5,7 @@ Random Rust exercises.
# Solutions
Currently solutions are only provided in a non-human-readable form in the page source.
Those are mostly inteded for testing that the exercise is even possible to solve.
Those are mostly intended for testing that the exercise is even possible to solve.
```rust
# /*
fn fix_me() { // Greyed out because the solution changes this line.