Closed johannesvollmer closed 2 years ago
What are the situations where using a builder is better than simply saying Update { id: 232323, .. Update::default() }
? Only when default
cannot have a nice default value for all the fields?
The builder is useful for stuff like SendMessageParams
. The Update
is never user generated. (Maybe in tests?)
Also Update::default()
wouldn't work as there is no derive(Default)
and it wouldn't even make sense as the id is unique and the update contains exactly one content thingy? The builder does handle fields with or without defaults and can check for required fields.
So yeah… I don't see a usecase for the Builder for the Update as every field is required anyway and the user wont be interested in constructing Updates.
Yeah, makes sense. For the sake of compilation speed, we should remove it.
released in 0.14.0
mem::size_of::<Update>()
went from30,384
to5,384
bytesSize of related objects
It is therefore advisable to reduce the size of the biggest structs that can occur inside an
UpdateContent
object, most importantlyCallbackQuery
andMessage
. TheCallbackQuery
contains a few small fields, except for one largeMessage
. Therefore, we only need to optimizeMessage
to reduce the total size of everyUpdate
.