mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-26 01:04:35 +02:00
parent
9a68434cac
commit
c8f626e573
@ -7,3 +7,8 @@
|
||||
```rust
|
||||
{{#include for-loops.rs}}
|
||||
```
|
||||
### Bonus question
|
||||
|
||||
It honestly doesn't work so well. It might seem that we could use a slice-of-slices (`&[&[i32]]`) as the input type to transpose and thus make our function handle any size of matrix. However, this quickly breaks down: the return type cannot be `&[&[i32]]` since it needs to own the data you return.
|
||||
|
||||
You can attempt to use something like `Vec<Vec<i32>>`, but this doesn't work very well either: it's hard to convert from `Vec<Vec<i32>>` to `&[&[i32]]` so now you cannot easily use `pretty_print` either.
|
Loading…
x
Reference in New Issue
Block a user