Skip to content

Commit

Permalink
Add more constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Montel committed Nov 28, 2023
1 parent 2d8b1cb commit 2daf1cd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/cxx-qt-lib/src/core/qcommandlineoption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qcommandlineoption_init_from_qcommandlineoption"]
fn construct(commandLineOption: &QCommandLineOption) -> QCommandLineOption;

#[doc(hidden)]
#[rust_name = "qcommandlineoption_init_from_qstring"]
fn construct(string: &QString) -> QCommandLineOption;

#[doc(hidden)]
#[rust_name = "qcommandlineoption_init_from_qstringlist"]
fn construct(names: &QStringList) -> QCommandLineOption;
}
}

Expand All @@ -70,6 +78,20 @@ impl Clone for QCommandLineOption {
}
}

impl From<&ffi::QString> for QCommandLineOption {
/// Constructs a command line option object with the name name.
fn from(name: &ffi::QString) -> Self {
ffi::qcommandlineoption_init_from_qstring(name)
}
}

impl From<&ffi::QStringList> for QCommandLineOption {
/// Constructs a command line option object with the name name.
fn from(names: &ffi::QStringList) -> Self {
ffi::qcommandlineoption_init_from_qstringlist(names)
}
}

// Safety:
//
// Static checks on the C++ side to ensure the size is the same.
Expand Down

0 comments on commit 2daf1cd

Please sign in to comment.