How can I ensure that all invocations of a method fn foo<T>(&self, x: T) where T: SomeTrait have the same concrete type for a specific instance of a struct?

I tried struct Thing<T> { field: u32 }, but that complains about an unused generic parameter, forcing me to place the <T> on the function. But placing it on the function allows multiple invocations with different concrete types over the life of Thing.

Is PhantomData the only option? I’d rather not use it to make struct construction easier.

My struct contains a few “graphical” items, that need to be laid out on a page. I want to make sure that each call to layout and item is called with an instance of the same kind of page, otherwise their final co-ordinates will be jumbled.

Now that I think about it, I might be able to just make the Layout struct have a reference to a page. I had been avoiding that because of lifetime issues, since I could not mutate the page as long as any layouts existed if the layouts had a reference to the page, but maybe I can use a second type (e.g. FinalisedLayout) that doesn’t hold a reference to work around that.