A crate for safe and ergonomic pin-projection.
APACHE-2.0 License
Bot releases are hidden (Show)
Published by taiki-e about 4 years ago
Published by taiki-e about 4 years ago
Remove deprecated #[project]
, #[project_ref]
, and #[project_replace]
attributes.
Name the projected type by passing an argument with the same name as the method to the #[pin_project]
attribute instead:
- #[pin_project]
+ #[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
- #[project]
fn func<T>(x: Pin<&mut Enum<T>>) {
- #[project]
match x.project() {
- Enum::Variant(_) => { /* ... */ }
+ EnumProj::Variant(_) => { /* ... */ }
}
}
Remove deprecated Replace
argument from #[pin_project]
attribute. Use project_replace
argument instead.
Raise the minimum supported Rust version of this crate from Rust 1.34 to Rust 1.37.
Suppress explicit_outlives_requirements
, box_pointers
, clippy::large_enum_variant
, clippy::pattern_type_mismatch
, clippy::implicit_return
, and clippy::redundant_pub_crate
lints in generated code. (#276, #277, #284)
Diagnostic improvements.
Changes since the 1.0.0-alpha.1 release:
Update minimal version of syn
to 1.0.44
Published by taiki-e about 4 years ago
Published by taiki-e about 4 years ago
Published by taiki-e about 4 years ago
Fix compatibility of generated code with forbid(future_incompatible)
Note: This does not guarantee compatibility with forbid(future_incompatible)
in the future.
If rustc adds a new lint, we may not be able to keep this.
Published by taiki-e about 4 years ago
Remove deprecated #[project]
, #[project_ref]
, and #[project_replace]
attributes.
Name the projected type by passing an argument with the same name as the method to the #[pin_project]
attribute instead:
- #[pin_project]
+ #[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
- #[project]
fn func<T>(x: Pin<&mut Enum<T>>) {
- #[project]
match x.project() {
- Enum::Variant(_) => { /* ... */ }
+ EnumProj::Variant(_) => { /* ... */ }
}
}
Remove deprecated Replace
argument from #[pin_project]
attribute. Use project_replace
argument instead.
Suppress explicit_outlives_requirements
, box_pointers
, clippy::large_enum_variant
, clippy::pattern_type_mismatch
, and clippy::implicit_return
lints in generated code. (#276, #277)
Diagnostic improvements.
See also tracking issue for 1.0 release.
Published by taiki-e about 4 years ago
Published by taiki-e over 4 years ago
Published by taiki-e over 4 years ago
Consider naming the projected type by passing an argument with the same name as the method to the #[pin_project] attribute instead.
use pin_project::pin_project;
use std::pin::Pin;
#[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
fn func<T>(x: Pin<&mut Enum<T>>) {
match x.project() {
EnumProj::Variant(y) => {
let _: Pin<&mut T> = y;
}
}
}
See #225 for more details.
Diagnostic improvements.
Published by taiki-e over 4 years ago
You can now use project_replace argument without Replace argument.
This used to require you to specify both.
- #[pin_project(Replace, project_replace = EnumProjOwn)]
+ #[pin_project(project_replace = EnumProjOwn)]
enum Enum<T> {
Variant(#[pin] T)
}
Makes project_replace
argument an alias for Replace
argument so that it can be used without a value.
#[pin_project(project_replace)]
enum Enum<T> {
Variant(#[pin] T)
}
The Replace
argument will be deprecated in the future.
Suppress unreachable_pub
lint in generated code.
Published by taiki-e over 4 years ago
Published by taiki-e over 4 years ago
Support Self
in more syntax positions inside #[pinned_drop]
impl.
Documentation improvements.
Diagnostic improvements.
Published by taiki-e over 4 years ago
Support naming the projection types.
By passing an argument with the same name as the method to the attribute, you can name the projection type returned from the method:
use pin_project::pin_project;
use std::pin::Pin;
#[pin_project(project = EnumProj)]
enum Enum<T> {
Variant(#[pin] T),
}
fn func<T>(x: Pin<&mut Enum<T>>) {
match x.project() {
EnumProj::Variant(y) => {
let _: Pin<&mut T> = y;
}
}
}
Published by taiki-e over 4 years ago
Published by taiki-e over 4 years ago
Published by taiki-e over 4 years ago
Added !Unpin
option to #[pin_project]
attribute for guarantee the type is !Unpin
.
use pin_project::pin_project;
#[pin_project(!Unpin)]
struct Struct<T, U> {
field: T,
}
This is equivalent to use #[pin]
attribute for PhantomPinned
field.
use pin_project::pin_project;
use std::marker::PhantomPinned;
#[pin_project]
struct Struct<T, U> {
field: T,
#[pin] // Note that using `PhantomPinned` without `#[pin]` attribute has no effect.
_pin: PhantomPinned,
}
Note: This raises the minimum supported Rust version of this crate from rustc 1.33 to rustc 1.34.
Fixed an issue where duplicate #[project]
attributes were ignored.
Hide generated items from --document-private-items. See #211 for more details.
Improve documentation
Published by taiki-e over 4 years ago
Published by taiki-e over 4 years ago
Published by taiki-e over 4 years ago