Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrary self types v2: book changes. #4174

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adetaylor
Copy link

@adetaylor adetaylor commented Dec 20, 2024

Preliminary book changes for Arbitrary Self Types v2.

The listing number is currently out of order and this will need fixing, I suspect, but keeping things there unchanged for reviewability meanwhile.

Tracking issue rust-lang/rust#44874

Preliminary book changes for Arbitrary Self Types v2.

The listing number is currently out of order and this will need fixing,
I suspect, but keeping things there unchanged for reviewability
meanwhile.
Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to flag up here that I have seen this, and that the content as written seems broadly good! However, I am marking it as “waiting on review” and will be mulling on how best to land it.

This definitely does belong in the reference, and it probably belongs in some kind of guide-like explanatory material somewhere, which might be The Book… but also might not.

At this point in the book, we have not yet talked about self: SomeType at all, other than a quick reference explaining that &self is a short way of writing self: &Self back in Chapter 5. We currently explicitly introduce self: SomeType very briefly in the new ch. 17 (currently available on nightly, will be stable with 1.85) to support discussing self: Pin<&mut Self>, and another brief discussion in the context of self: Box<Self> in ch. 18.

That is suggestive, though: custom self types are relatively advanced material that the book does not cover at all. (See also #4104, which has a similar challenge.)

Net, I am not yet sure which of the following categories this fits into:

  • It may belong in the book, in which case:
    • This may not be the right spot for it. It might be better situated in the Advanced Traits or Advanced Types sections of what is now Ch. 20.
    • If this is the right spot for it—and given the surrounding discussion of Deref, it may be—, we will need to expand it a bit, given this is the introduction of the whole concept for the first time. We will also want to tweak the examples if we can to fit more with the flow of the types around it in that case.
  • It may also not belong in the book at all, as just too niche/advanced a topic to get into. There are, as Lacking explanation of mutable globals (static mut alternatives) #4104 suggests, a fair number of these, and this is an open problem we need to solve at the project level.

@carols10cents and I will think about it and let you all know what we think, but heads up that it's almost certainly going to be after the holidays, as I am off for the next couple weeks!

@adetaylor
Copy link
Author

Hi Chris! Thanks for the early feedback, and yeah, I'm not sure either. I don't consider this PR even remotely ready for review but the sort of directional feedback you're giving is exactly what I do need at this stage, so thanks for taking a look at an early draft CL. I'm also away for most of the next three weeks. See you in the new year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants