HackerTrans
トップ新着トレンドコメント過去質問紹介求人

jiwangcdi

no profile record

コメント

jiwangcdi
·2 年前·議論
So abstraction is still a point, but Rust cares about memory layout as well.
jiwangcdi
·2 年前·議論
Then if Path is not about abstraction, why not use a raw byte slice like &[u8]
jiwangcdi
·2 年前·議論
> The next noisy element is the <P: AsRef<Path>> constraint. It is needed because Rust loves exposing physical layout of bytes in memory as an interface, specifically for cases where that brings performance. In particular, the meaning of Path is not that it is some abstract representation of a file path, but that it is just literally a bunch of contiguous bytes in memory.

I can't understand this. Isn't this for polymorphism like what we do this:

```rust fn some_function(a: impl ToString) -> String { a.to_string(); } ```

What to do with memory layout? Thanks for any explanation.