These are chat archives for rust-lang/rust

Feb 2019
Feb 17 05:27

I am trying to create a macro to reduce Diesel boilerplate:

macro_rules! diesel_struct {
            pub struct $struct_name:ident, $new_struct_name: ident [$table_name: literal]{
                $(pub $field:ident : $type:ty,)*
    ) => (
            #[table_name = $table_name]
            pub struct $struct_name {
                pub id: i32,
                $(pub $field: $type),*

            #[table_name = $table_name]
            pub struct $new_struct_name {
                $(pub $field: $type),*

But this is giving me error:
The attribute table_name is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)

How to overcome this error?

Should I add #![feature(custom_attribute)] to the crate attributes?
Since I am not defining a new attribute, I'm just assigning to an already defined one.
Michal 'vorner' Vaner
Feb 17 17:14

@rajasekarv My gut feeling about the goals of the library is „What could possibly go wrong?“ and if I wanted some kind of distributed computation, I would send explicit „commands“ (an enum or something, that I would match and dispatch on the receiver side). That is probably somewhat more work, but with more feeling like I know what it does.

However, that might be just the first impression or personal preference

Feb 17 21:00
If you have a Vec<Vec<u8>>. The outer vector only contains pointers, right? So there's no wasted space if the inner vectors are of much different length?
Feb 17 21:02
bspeice Vec contains a pointer to the storage, and two extra usize for length and capacity. The inner vectors can be different length/capacity, so it's not a true "matrix" storage.