mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-22 23:05:22 +02:00
Adding a link to Solutions from for-loops.md and extending the answer to the bonus questions. (#213)
* Update for-loops.md * Update solutions-morning.md
This commit is contained in:
parent
4760295030
commit
ec7125da2e
@ -73,3 +73,10 @@ slice-of-slices. Why or why not?
|
|||||||
|
|
||||||
See the [`ndarray` crate](https://docs.rs/ndarray/) for a production quality
|
See the [`ndarray` crate](https://docs.rs/ndarray/) for a production quality
|
||||||
implementation.
|
implementation.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
The solution and the answer to the bonus section are available in the
|
||||||
|
[Solution](solutions-morning.md#arrays-and-for-loops) section.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
@ -11,4 +11,6 @@
|
|||||||
|
|
||||||
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.
|
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.
|
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.
|
||||||
|
|
||||||
|
In addition, the type itself would not enforce that the child slices are of the same length, so such variable could contain an invalid matrix.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user