Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
Fixed Q_LISTMODEL macro with a single element
Browse files Browse the repository at this point in the history
Rust sees (ident) as an expression, but (ident,) as a tuple.
Fixes #16.
  • Loading branch information
White-Oak committed Oct 17, 2016
1 parent 700962c commit 6ebb045
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion examples/listmodel_macro.rs
Expand Up @@ -7,7 +7,13 @@ use qml::*;
Q_LISTMODEL!{
pub QTestModel {
name: String,
number: i32,
number: i32
}
}

Q_LISTMODEL!{
pub QOneMemberModel {
name: String
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/macros.rs
Expand Up @@ -288,7 +288,7 @@ macro_rules! Q_OBJECT{
#[macro_export]
macro_rules! Q_LISTMODEL{
(pub $wrapper:ident{
$($rolename:ident : $roletype:ty,)*
$($rolename:ident : $roletype:ident),*
}) => {
pub struct $wrapper {
qalm: Box<QListModel<'static>>,
Expand Down Expand Up @@ -322,9 +322,9 @@ macro_rules! Q_LISTMODEL{

/// Sets a specified data for this model
#[allow(unused_mut)]
pub fn set_data(&mut self, vec: Vec<($($roletype),*)>) {
pub fn set_data(&mut self, vec: Vec<($($roletype,)*)>) {
self.qalm.set_data(vec.into_iter()
.map(|($($rolename),*)| {
.map(|($($rolename,)*)| {
let mut vec = Vec::new();
$(
vec.push($rolename.into());
Expand Down

0 comments on commit 6ebb045

Please sign in to comment.