---
title: "Comment by Oscar Ablinger on \"Self Referential Structs in Rust (Part 1)\" | Hashnode"
description: "Good post! Made me understand pinning ^^ I only wish rust had a way to force immutability on a boxed value together with a lifetime. I mean something like this:"
url: "https://hashnode.com/posts/self-referential-structs-in-rust/61837eaefd5d634d016966d6/comment/66cdec8b67b8ffe5784d2bb8"
---

[Discussion](https://hashnode.com/posts/self-referential-structs-in-rust/61837eaefd5d634d016966d6)

Comment [Self Referential Structs in Rust (Part 1)](https://hashnode.com/posts/self-referential-structs-in-rust/61837eaefd5d634d016966d6)

[Oscar Ablinger](https://hashnode.com/@OscarAblinger)

[Aug 27, 2024](https://hashnode.com/posts/self-referential-structs-in-rust/61837eaefd5d634d016966d6/comment/66cdec8b67b8ffe5784d2bb8)

Good post! Made me understand pinning ^^

I only wish rust had a way to force immutability on a boxed value together with a lifetime. I mean something like this:

```
struct URI<'a> {
  raw: String<'a>,
  pub protocol: &'a str,
}
```

Assuming `protocol` points to a substring of `raw`, my understanding is, that this would be entirely unproblematic unless someone mutates `raw`. Since it's not public and none of the implemented methods for it, mutate it, is there any example of where this could lead to a dangling reference?

And with the lifetime on `String`, rust could ensure that, while `raw` may still be changed, the previous string would still have to be available for at least `'a`, ensuring that it won't break `protocol`.

I'm never sure whether I should be happy that rust "thinks of everything" and won't let me write potentially problematic code, or whether I just want to tell rust "trust me bro", because it doesn't apply to the actual code…
