Skip to content

Conversation

@louwenus
Copy link

Behavior on existing syntax is kept as is.
The new syntax look like this:

# use pin_project::pin_project
#[pin_project(pub project = StructProj)] //force the project method and StructProj to be pub
pub struct Struct<T> {
    #[pin]
    field: T,
}

pub prefix can also be used on project_ref and (named) project_replace

fix #361

Copy link
Owner

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good to me.

Could you also add tests/expand test case for pub project_replace = ...?

@louwenus
Copy link
Author

louwenus commented Sep 2, 2025

I edited as you asked (test cases, better error message / fixed expectation and unreachable)

I had different output than the CI on some stderr, but it seem in the end there is no change from previously in the repo.

@louwenus louwenus requested a review from taiki-e September 2, 2025 18:29
Copy link
Owner

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

Thanks.

I noticed you also mentioned about documentation in #361. For now, I think it's okay to use allow(missing_docs) (or simple docs), but could you add test cases to tests/include/basic-safe-part.rs to see if it works?

@louwenus
Copy link
Author

louwenus commented Sep 3, 2025

I added some simple doc for the structs and methods (feel free to correct/modify them(you should have edit rigths) and/or tell me what to change if they are unclear/incomplete/have grammar errors ...)

for the fields, I copy the referenced field doc without any change.

also, the #[allow] where not copied over from the struct definition to the project struct, leading to clippy errors (about public not non-exhaustive structs)

For now i simply added a #[non-exhaustive] to the generated struct / enum, which seem a bit hacky to me but quite reasonable as we may want to add some fields of our own (like some PhantomData maybe), and solve the immediate problem of passing the CI

As long as the user is reasonable, as in, do not use some name that need #[allow], i do not see many other use-case where the public struct could need some attribute to make it correct for the public interface, but i could be wrong

A more clean solution could be to copy some attribute and/or add a syntax to add attributes to the generated structs (which could be used for other purposes like derive(Debug) and similar ). What do you think about it ? (I could do that in a following PR if you want)

@louwenus louwenus requested a review from taiki-e September 3, 2025 22:13
@louwenus
Copy link
Author

louwenus commented Sep 3, 2025

PS: Sorry for the numerous commit if that make less readable for you ... I was not as exhaustive in my pre-push tests than your amazing CI which made me correct my code over and over.

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.

Allow pub visibility as an option

2 participants