Skip to content

Wrong default value generation for Option<Arc<>> types #60

Description

@Mixa84

This struct:

#[derive(uniffi::Record)]
pub struct BoltzSessionBuilder {
    ...
    #[uniffi(default = None)]
    mnemonic: Option<Arc<Mnemonic>>,
    #[uniffi(default = None)]
    logging: Option<Arc<dyn Logging>>,
    ...
}

Gets converted to this:

struct BoltzSessionBuilder {
    ...
    std::shared_ptr<Mnemonic> mnemonic = std::nullopt;
    std::shared_ptr<Logging> logging = std::nullopt;
    ...
};

The Option<Arc<Mnemonic> is flattened to std::shared_ptr<Mnemonic> as shared pointer can be without pointing to object so it has a behavior as optional, but the default values are kept as it is std::optional<>. Same for logging!

Question here is, is this a bug or there is correct approach to avoid this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions