Skip to content

Commit 9b3758b

Browse files
committed
assume plain enum is Copy
1 parent 0e3d511 commit 9b3758b

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

crates/bindings-macro/src/sats.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,12 @@ pub(crate) fn derive_satstype(ty: &SatsType<'_>) -> TokenStream {
215215
let mut generics = ty.generics.clone();
216216
add_type_bounds(&mut generics, &quote!(#krate::FilterableValue));
217217
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
218-
// As we don't have access to other `derive` attributes,
219-
// we don't know if `Copy` was derived,
220-
// so we won't impl for the owned type.
218+
// Assume that the type is `Copy`, as most all-unit enums will be.
221219
let filterable_impl = quote! {
220+
#[automatically_derived]
221+
impl #impl_generics #krate::FilterableValue for #name #ty_generics #where_clause {
222+
type Column = #name #ty_generics;
223+
}
222224
#[automatically_derived]
223225
impl #impl_generics #krate::FilterableValue for &#name #ty_generics #where_clause {
224226
type Column = #name #ty_generics;

crates/lib/src/filterable_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub enum TermBound<T> {
8787
}
8888
impl<Bound: FilterableValue> TermBound<&Bound> {
8989
#[inline]
90-
/// If `self` is [`TermBound::Range`], returns the `rend_idx` value for [`BTreeScanArgs`],
90+
/// If `self` is [`TermBound::Range`], returns the `rend_idx` value for `IndexScanRangeArgs`,
9191
/// i.e. the index in `buf` of the first byte in the end range
9292
pub fn serialize_into(&self, buf: &mut Vec<u8>) -> Option<usize> {
9393
let (start, end) = match self {

modules/sdk-test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ define_tables! {
550550

551551
#[spacetimedb::reducer]
552552
fn update_pk_simple_enum(ctx: &ReducerContext, a: SimpleEnum, data: i32) -> anyhow::Result<()> {
553-
let Some(mut o) = ctx.db.pk_simple_enum().a().find(&a) else {
553+
let Some(mut o) = ctx.db.pk_simple_enum().a().find(a) else {
554554
return Err(anyhow!("row not found"));
555555
};
556556
o.data = data;

0 commit comments

Comments
 (0)