It's a very different kind of borrow checking than Rust's. For example there's no mutability xor sharing checking, because mutability cannot invalidate memory (there's still a GC in C# after all!). As such, Rust's NLL (which are available in the 2015 edition too btw) don't really make sense in C#.
- Posts
- 1
- Comments
- 50
- Joined
- 3 yr. ago
- Posts
- 1
- Comments
- 50
- Joined
- 3 yr. ago
I can agree that the example function is not the best usecase. But the point still stand that there's no realistic escape hatch from lifetimes and memory management in Rust.
Cowdoes not work when you are actually required to return a reference, e.g. if you're working with some other crate that requires that.Cowalso has some more strict requirements on reborrows (i.e. you can reborrow a&'short &'long Tto a&'long T, but you can only reborrow a&'short Cow<'long, T>to a&'short T).LazyLockcan solve very specific issues likestatic, but is not a general escape hatch. Again, the example is not the best to showcase this, but imagine if you have to perform this operation for an unknown amount of runtime values.LazyLockwill only work for the very first one.