Update Strum (#2088)
* Update Strum * Change log update * Fetch updates from upstream Strum * build-tools/update-strum-macros.sh * Revert "Fetch updates from upstream Strum" This reverts commit 32cf8f7ac96f9b0431d2bde682b69ec44b4f5b2e. * Update enum_iter.rs --------- Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
This commit is contained in:
parent
3e149db180
commit
0adcd3b36c
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 1.0.0-rc.2 - Pending
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
* Updated Strum to version 0.26 https://github.com/SeaQL/sea-orm/pull/2088
|
||||
|
||||
## 1.0.0-rc.1 - 2024-02-06
|
||||
|
||||
### Breaking Changes
|
||||
|
@ -36,7 +36,7 @@ bigdecimal = { version = "0.3", default-features = false, optional = true }
|
||||
sea-orm-macros = { version = "1.0.0-rc.1", path = "sea-orm-macros", default-features = false, features = ["strum"] }
|
||||
sea-query = { version = "0.31.0-rc.3", default-features = false, features = ["thread-safe", "hashable-value", "backend-mysql", "backend-postgres", "backend-sqlite"] }
|
||||
sea-query-binder = { version = "0.6.0-rc.1", default-features = false, optional = true }
|
||||
strum = { version = "0.25", default-features = false }
|
||||
strum = { version = "0.26", default-features = false }
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_json = { version = "1.0", default-features = false, optional = true }
|
||||
sqlx = { version = "0.7", default-features = false, optional = true }
|
||||
|
8
build-tools/update-strum-macros.sh
Normal file
8
build-tools/update-strum-macros.sh
Normal file
@ -0,0 +1,8 @@
|
||||
rm -rf sea-orm-macros/src/strum/helpers
|
||||
rm -rf sea-orm-macros/src/strum/enum_iter.rs
|
||||
|
||||
cp -r ../strum/strum_macros/src/helpers sea-orm-macros/src/strum/helpers
|
||||
cp -r ../strum/strum_macros/src/macros/enum_iter.rs sea-orm-macros/src/strum/enum_iter.rs
|
||||
|
||||
sed -i 's/crate::helpers::{*/super::helpers::{/' sea-orm-macros/src/strum/enum_iter.rs
|
||||
sed -i 's/parse_quote!(::strum)*/parse_quote!(sea_orm::strum)/' sea-orm-macros/src/strum/helpers/type_props.rs
|
@ -74,14 +74,14 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
|
||||
#[allow(
|
||||
missing_copy_implementations,
|
||||
)]
|
||||
#vis struct #iter_name #ty_generics {
|
||||
#vis struct #iter_name #impl_generics {
|
||||
idx: usize,
|
||||
back_idx: usize,
|
||||
marker: ::core::marker::PhantomData #phantom_data,
|
||||
}
|
||||
|
||||
impl #impl_generics core::fmt::Debug for #iter_name #ty_generics #where_clause {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
impl #impl_generics ::core::fmt::Debug for #iter_name #ty_generics #where_clause {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
// We don't know if the variants implement debug themselves so the only thing we
|
||||
// can really show is how many elements are left.
|
||||
f.debug_struct(#iter_name_debug_struct)
|
||||
@ -91,7 +91,7 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
|
||||
}
|
||||
|
||||
impl #impl_generics #iter_name #ty_generics #where_clause {
|
||||
fn get(&self, idx: usize) -> Option<#name #ty_generics> {
|
||||
fn get(&self, idx: usize) -> ::core::option::Option<#name #ty_generics> {
|
||||
match idx {
|
||||
#(#arms),*
|
||||
}
|
||||
@ -112,16 +112,16 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
|
||||
impl #impl_generics Iterator for #iter_name #ty_generics #where_clause {
|
||||
type Item = #name #ty_generics;
|
||||
|
||||
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
|
||||
fn next(&mut self) -> ::core::option::Option<<Self as Iterator>::Item> {
|
||||
self.nth(0)
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
fn size_hint(&self) -> (usize, ::core::option::Option<usize>) {
|
||||
let t = if self.idx + self.back_idx >= #variant_count { 0 } else { #variant_count - self.idx - self.back_idx };
|
||||
(t, Some(t))
|
||||
}
|
||||
|
||||
fn nth(&mut self, n: usize) -> Option<<Self as Iterator>::Item> {
|
||||
fn nth(&mut self, n: usize) -> ::core::option::Option<<Self as Iterator>::Item> {
|
||||
let idx = self.idx + n + 1;
|
||||
if idx + self.back_idx > #variant_count {
|
||||
// We went past the end of the iterator. Freeze idx at #variant_count
|
||||
@ -143,7 +143,7 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
|
||||
}
|
||||
|
||||
impl #impl_generics DoubleEndedIterator for #iter_name #ty_generics #where_clause {
|
||||
fn next_back(&mut self) -> Option<<Self as Iterator>::Item> {
|
||||
fn next_back(&mut self) -> ::core::option::Option<<Self as Iterator>::Item> {
|
||||
let back_idx = self.back_idx + 1;
|
||||
|
||||
if self.idx + back_idx > #variant_count {
|
||||
@ -159,6 +159,8 @@ pub fn enum_iter_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
|
||||
}
|
||||
}
|
||||
|
||||
impl #impl_generics ::core::iter::FusedIterator for #iter_name #ty_generics #where_clause { }
|
||||
|
||||
impl #impl_generics Clone for #iter_name #ty_generics #where_clause {
|
||||
fn clone(&self) -> #iter_name #ty_generics {
|
||||
#iter_name {
|
||||
|
Loading…
x
Reference in New Issue
Block a user