Rust api guidelines say constructors should be called "new"
parent
d60d4cd5ee
commit
e42c2411f7
|
@ -61,7 +61,7 @@ pub struct Person {
|
|||
/// Implementation of the binding
|
||||
impl PersonTrait for Person {
|
||||
/// Create a new person with default data.
|
||||
fn create(emit: PersonEmitter) -> Person {
|
||||
fn new(emit: PersonEmitter) -> Person {
|
||||
Person {
|
||||
emit: emit,
|
||||
name: String::new(),
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct Demo {
|
|||
}
|
||||
|
||||
impl DemoTrait for Demo {
|
||||
fn create(emit: DemoEmitter,
|
||||
fn new(emit: DemoEmitter,
|
||||
fibonacci: Fibonacci,
|
||||
fibonacci_list: FibonacciList,
|
||||
file_system_tree: FileSystemTree,
|
||||
|
|
|
@ -28,7 +28,7 @@ pub struct Fibonacci {
|
|||
}
|
||||
|
||||
impl FibonacciTrait for Fibonacci {
|
||||
fn create(emit: FibonacciEmitter) -> Fibonacci {
|
||||
fn new(emit: FibonacciEmitter) -> Fibonacci {
|
||||
Fibonacci {
|
||||
emit: emit,
|
||||
input: 0,
|
||||
|
@ -64,7 +64,7 @@ pub struct FibonacciList {
|
|||
}
|
||||
|
||||
impl FibonacciListTrait for FibonacciList {
|
||||
fn create(emit: FibonacciListEmitter, _: FibonacciListList) -> FibonacciList {
|
||||
fn new(emit: FibonacciListEmitter, _: FibonacciListList) -> FibonacciList {
|
||||
FibonacciList {
|
||||
emit: emit,
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ pub struct DirEntry {
|
|||
type Incoming<T> = Arc<Mutex<HashMap<usize, Vec<T>>>>;
|
||||
|
||||
impl Item for DirEntry {
|
||||
fn create(name: &str) -> DirEntry {
|
||||
fn new(name: &str) -> DirEntry {
|
||||
DirEntry {
|
||||
name: OsString::from(name),
|
||||
metadata: metadata(name).ok(),
|
||||
|
@ -85,7 +85,7 @@ impl Default for DirEntry {
|
|||
}
|
||||
|
||||
pub trait Item: Default {
|
||||
fn create(name: &str) -> Self;
|
||||
fn new(name: &str) -> Self;
|
||||
fn can_fetch_more(&self) -> bool;
|
||||
fn retrieve(id: usize, parents: Vec<&Self>, q: Incoming<Self>, emit: FileSystemTreeEmitter);
|
||||
fn file_name(&self) -> String;
|
||||
|
@ -125,7 +125,7 @@ where
|
|||
parent: None,
|
||||
row: 0,
|
||||
children: None,
|
||||
data: T::create(path),
|
||||
data: T::new(path),
|
||||
};
|
||||
self.entries.push(root);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ impl<T: Item> FileSystemTreeTrait for RGeneralItemModel<T>
|
|||
where
|
||||
T: Sync + Send,
|
||||
{
|
||||
fn create(emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self {
|
||||
fn new(emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self {
|
||||
let mut tree = RGeneralItemModel {
|
||||
emit: emit,
|
||||
model: model,
|
||||
|
|
|
@ -303,7 +303,7 @@ fn sync_tree(
|
|||
}
|
||||
|
||||
impl ProcessesTrait for Processes {
|
||||
fn create(emit: ProcessesEmitter, model: ProcessesTree) -> Processes {
|
||||
fn new(emit: ProcessesEmitter, model: ProcessesTree) -> Processes {
|
||||
let (tx, rx) = channel();
|
||||
let p = Processes {
|
||||
emit: emit.clone(),
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct TimeSeries {
|
|||
}
|
||||
|
||||
impl TimeSeriesTrait for TimeSeries {
|
||||
fn create(emit: TimeSeriesEmitter, _: TimeSeriesList) -> TimeSeries {
|
||||
fn new(emit: TimeSeriesEmitter, _: TimeSeriesList) -> TimeSeries {
|
||||
let mut series = TimeSeries {
|
||||
emit: emit,
|
||||
list: Vec::new(),
|
||||
|
|
|
@ -125,7 +125,7 @@ impl DemoEmitter {
|
|||
}
|
||||
|
||||
pub trait DemoTrait {
|
||||
fn create(emit: DemoEmitter,
|
||||
fn new(emit: DemoEmitter,
|
||||
fibonacci: Fibonacci,
|
||||
fibonacci_list: FibonacciList,
|
||||
file_system_tree: FileSystemTree,
|
||||
|
@ -194,7 +194,7 @@ pub extern "C" fn demo_new(
|
|||
input_changed: input_changed,
|
||||
result_changed: result_changed,
|
||||
};
|
||||
let d_fibonacci = Fibonacci::create(fibonacci_emit);
|
||||
let d_fibonacci = Fibonacci::new(fibonacci_emit);
|
||||
let fibonacci_list_emit = FibonacciListEmitter {
|
||||
qobject: Arc::new(Mutex::new(fibonacci_list)),
|
||||
new_data_ready: fibonacci_list_new_data_ready,
|
||||
|
@ -209,7 +209,7 @@ pub extern "C" fn demo_new(
|
|||
begin_remove_rows: fibonacci_list_begin_remove_rows,
|
||||
end_remove_rows: fibonacci_list_end_remove_rows,
|
||||
};
|
||||
let d_fibonacci_list = FibonacciList::create(fibonacci_list_emit, model);
|
||||
let d_fibonacci_list = FibonacciList::new(fibonacci_list_emit, model);
|
||||
let file_system_tree_emit = FileSystemTreeEmitter {
|
||||
qobject: Arc::new(Mutex::new(file_system_tree)),
|
||||
path_changed: path_changed,
|
||||
|
@ -225,7 +225,7 @@ pub extern "C" fn demo_new(
|
|||
begin_remove_rows: file_system_tree_begin_remove_rows,
|
||||
end_remove_rows: file_system_tree_end_remove_rows,
|
||||
};
|
||||
let d_file_system_tree = FileSystemTree::create(file_system_tree_emit, model);
|
||||
let d_file_system_tree = FileSystemTree::new(file_system_tree_emit, model);
|
||||
let processes_emit = ProcessesEmitter {
|
||||
qobject: Arc::new(Mutex::new(processes)),
|
||||
active_changed: active_changed,
|
||||
|
@ -241,7 +241,7 @@ pub extern "C" fn demo_new(
|
|||
begin_remove_rows: processes_begin_remove_rows,
|
||||
end_remove_rows: processes_end_remove_rows,
|
||||
};
|
||||
let d_processes = Processes::create(processes_emit, model);
|
||||
let d_processes = Processes::new(processes_emit, model);
|
||||
let time_series_emit = TimeSeriesEmitter {
|
||||
qobject: Arc::new(Mutex::new(time_series)),
|
||||
new_data_ready: time_series_new_data_ready,
|
||||
|
@ -256,11 +256,11 @@ pub extern "C" fn demo_new(
|
|||
begin_remove_rows: time_series_begin_remove_rows,
|
||||
end_remove_rows: time_series_end_remove_rows,
|
||||
};
|
||||
let d_time_series = TimeSeries::create(time_series_emit, model);
|
||||
let d_time_series = TimeSeries::new(time_series_emit, model);
|
||||
let demo_emit = DemoEmitter {
|
||||
qobject: Arc::new(Mutex::new(demo)),
|
||||
};
|
||||
let d_demo = Demo::create(demo_emit,
|
||||
let d_demo = Demo::new(demo_emit,
|
||||
d_fibonacci,
|
||||
d_fibonacci_list,
|
||||
d_file_system_tree,
|
||||
|
@ -329,7 +329,7 @@ impl FibonacciEmitter {
|
|||
}
|
||||
|
||||
pub trait FibonacciTrait {
|
||||
fn create(emit: FibonacciEmitter) -> Self;
|
||||
fn new(emit: FibonacciEmitter) -> Self;
|
||||
fn emit(&self) -> &FibonacciEmitter;
|
||||
fn input(&self) -> u32;
|
||||
fn set_input(&mut self, value: u32);
|
||||
|
@ -347,7 +347,7 @@ pub extern "C" fn fibonacci_new(
|
|||
input_changed: input_changed,
|
||||
result_changed: result_changed,
|
||||
};
|
||||
let d_fibonacci = Fibonacci::create(fibonacci_emit);
|
||||
let d_fibonacci = Fibonacci::new(fibonacci_emit);
|
||||
Box::into_raw(Box::new(d_fibonacci))
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ impl FibonacciListList {
|
|||
}
|
||||
|
||||
pub trait FibonacciListTrait {
|
||||
fn create(emit: FibonacciListEmitter, model: FibonacciListList) -> Self;
|
||||
fn new(emit: FibonacciListEmitter, model: FibonacciListList) -> Self;
|
||||
fn emit(&self) -> &FibonacciListEmitter;
|
||||
fn row_count(&self) -> usize;
|
||||
fn can_fetch_more(&self) -> bool {
|
||||
|
@ -467,7 +467,7 @@ pub extern "C" fn fibonacci_list_new(
|
|||
begin_remove_rows: fibonacci_list_begin_remove_rows,
|
||||
end_remove_rows: fibonacci_list_end_remove_rows,
|
||||
};
|
||||
let d_fibonacci_list = FibonacciList::create(fibonacci_list_emit, model);
|
||||
let d_fibonacci_list = FibonacciList::new(fibonacci_list_emit, model);
|
||||
Box::into_raw(Box::new(d_fibonacci_list))
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,7 @@ impl FileSystemTreeTree {
|
|||
}
|
||||
|
||||
pub trait FileSystemTreeTrait {
|
||||
fn create(emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self;
|
||||
fn new(emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self;
|
||||
fn emit(&self) -> &FileSystemTreeEmitter;
|
||||
fn path(&self) -> Option<&str>;
|
||||
fn set_path(&mut self, value: Option<String>);
|
||||
|
@ -621,7 +621,7 @@ pub extern "C" fn file_system_tree_new(
|
|||
begin_remove_rows: file_system_tree_begin_remove_rows,
|
||||
end_remove_rows: file_system_tree_end_remove_rows,
|
||||
};
|
||||
let d_file_system_tree = FileSystemTree::create(file_system_tree_emit, model);
|
||||
let d_file_system_tree = FileSystemTree::new(file_system_tree_emit, model);
|
||||
Box::into_raw(Box::new(d_file_system_tree))
|
||||
}
|
||||
|
||||
|
@ -835,7 +835,7 @@ impl ProcessesTree {
|
|||
}
|
||||
|
||||
pub trait ProcessesTrait {
|
||||
fn create(emit: ProcessesEmitter, model: ProcessesTree) -> Self;
|
||||
fn new(emit: ProcessesEmitter, model: ProcessesTree) -> Self;
|
||||
fn emit(&self) -> &ProcessesEmitter;
|
||||
fn active(&self) -> bool;
|
||||
fn set_active(&mut self, value: bool);
|
||||
|
@ -885,7 +885,7 @@ pub extern "C" fn processes_new(
|
|||
begin_remove_rows: processes_begin_remove_rows,
|
||||
end_remove_rows: processes_end_remove_rows,
|
||||
};
|
||||
let d_processes = Processes::create(processes_emit, model);
|
||||
let d_processes = Processes::new(processes_emit, model);
|
||||
Box::into_raw(Box::new(d_processes))
|
||||
}
|
||||
|
||||
|
@ -1079,7 +1079,7 @@ impl TimeSeriesList {
|
|||
}
|
||||
|
||||
pub trait TimeSeriesTrait {
|
||||
fn create(emit: TimeSeriesEmitter, model: TimeSeriesList) -> Self;
|
||||
fn new(emit: TimeSeriesEmitter, model: TimeSeriesList) -> Self;
|
||||
fn emit(&self) -> &TimeSeriesEmitter;
|
||||
fn row_count(&self) -> usize;
|
||||
fn can_fetch_more(&self) -> bool {
|
||||
|
@ -1121,7 +1121,7 @@ pub extern "C" fn time_series_new(
|
|||
begin_remove_rows: time_series_begin_remove_rows,
|
||||
end_remove_rows: time_series_end_remove_rows,
|
||||
};
|
||||
let d_time_series = TimeSeries::create(time_series_emit, model);
|
||||
let d_time_series = TimeSeries::new(time_series_emit, model);
|
||||
Box::into_raw(Box::new(d_time_series))
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ void rConstructorArgs(QTextStream& r, const QString& name, const Object& o, cons
|
|||
end_remove_rows: %4_end_remove_rows,
|
||||
)").arg(o.name, type, snakeCase(name), snakeCase(o.name));
|
||||
}
|
||||
r << QString(" };\n let d_%3 = %1::create(%3_emit%2")
|
||||
r << QString(" };\n let d_%3 = %1::new(%3_emit%2")
|
||||
.arg(o.name, model, snakeCase(name));
|
||||
for (const Property& p: o.properties) {
|
||||
if (p.type.type == BindingType::Object) {
|
||||
|
@ -241,7 +241,7 @@ impl %1%2 {
|
|||
r << QString(R"(}
|
||||
|
||||
pub trait %1Trait {
|
||||
fn create(emit: %1Emitter%2)").arg(o.name, modelStruct);
|
||||
fn new(emit: %1Emitter%2)").arg(o.name, modelStruct);
|
||||
for (const Property& p: o.properties) {
|
||||
if (p.type.type == BindingType::Object) {
|
||||
r << ",\n " << snakeCase(p.name) << ": " << p.type.name;
|
||||
|
@ -762,7 +762,7 @@ void writeRustImplementationObject(QTextStream& r, const Object& o) {
|
|||
}
|
||||
}
|
||||
r << QString(R"(impl %1Trait for %1 {
|
||||
fn create(emit: %1Emitter%2) -> %1 {
|
||||
fn new(emit: %1Emitter%2) -> %1 {
|
||||
%1 {
|
||||
emit: emit,
|
||||
)").arg(o.name, modelStruct);
|
||||
|
|
|
@ -15,7 +15,7 @@ pub struct Persons {
|
|||
}
|
||||
|
||||
impl PersonsTrait for Persons {
|
||||
fn create(emit: PersonsEmitter, model: PersonsList) -> Persons {
|
||||
fn new(emit: PersonsEmitter, model: PersonsList) -> Persons {
|
||||
Persons {
|
||||
emit: emit,
|
||||
model: model,
|
||||
|
|
|
@ -144,7 +144,7 @@ impl PersonsList {
|
|||
}
|
||||
|
||||
pub trait PersonsTrait {
|
||||
fn create(emit: PersonsEmitter, model: PersonsList) -> Self;
|
||||
fn new(emit: PersonsEmitter, model: PersonsList) -> Self;
|
||||
fn emit(&self) -> &PersonsEmitter;
|
||||
fn row_count(&self) -> usize;
|
||||
fn can_fetch_more(&self) -> bool {
|
||||
|
@ -182,7 +182,7 @@ pub extern "C" fn persons_new(
|
|||
begin_remove_rows: persons_begin_remove_rows,
|
||||
end_remove_rows: persons_end_remove_rows,
|
||||
};
|
||||
let d_persons = Persons::create(persons_emit, model);
|
||||
let d_persons = Persons::new(persons_emit, model);
|
||||
Box::into_raw(Box::new(d_persons))
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct Person {
|
|||
}
|
||||
|
||||
impl PersonTrait for Person {
|
||||
fn create(emit: PersonEmitter) -> Person {
|
||||
fn new(emit: PersonEmitter) -> Person {
|
||||
Person {
|
||||
emit: emit,
|
||||
user_name: String::new(),
|
||||
|
|
|
@ -70,7 +70,7 @@ impl PersonEmitter {
|
|||
}
|
||||
|
||||
pub trait PersonTrait {
|
||||
fn create(emit: PersonEmitter) -> Self;
|
||||
fn new(emit: PersonEmitter) -> Self;
|
||||
fn emit(&self) -> &PersonEmitter;
|
||||
fn user_name(&self) -> &str;
|
||||
fn set_user_name(&mut self, value: String);
|
||||
|
@ -85,7 +85,7 @@ pub extern "C" fn person_new(
|
|||
qobject: Arc::new(Mutex::new(person)),
|
||||
user_name_changed: user_name_changed,
|
||||
};
|
||||
let d_person = Person::create(person_emit);
|
||||
let d_person = Person::new(person_emit);
|
||||
Box::into_raw(Box::new(d_person))
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ pub struct Object {
|
|||
}
|
||||
|
||||
impl ObjectTrait for Object {
|
||||
fn create(emit: ObjectEmitter) -> Object {
|
||||
fn new(emit: ObjectEmitter) -> Object {
|
||||
Object {
|
||||
emit: emit,
|
||||
boolean: true,
|
||||
|
|
|
@ -168,7 +168,7 @@ impl ObjectEmitter {
|
|||
}
|
||||
|
||||
pub trait ObjectTrait {
|
||||
fn create(emit: ObjectEmitter) -> Self;
|
||||
fn new(emit: ObjectEmitter) -> Self;
|
||||
fn emit(&self) -> &ObjectEmitter;
|
||||
fn boolean(&self) -> bool;
|
||||
fn set_boolean(&mut self, value: bool);
|
||||
|
@ -211,7 +211,7 @@ pub extern "C" fn object_new(
|
|||
u64_changed: u64_changed,
|
||||
uinteger_changed: uinteger_changed,
|
||||
};
|
||||
let d_object = Object::create(object_emit);
|
||||
let d_object = Object::new(object_emit);
|
||||
Box::into_raw(Box::new(d_object))
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct Group {
|
|||
}
|
||||
|
||||
impl GroupTrait for Group {
|
||||
fn create(emit: GroupEmitter, person: Person) -> Group {
|
||||
fn new(emit: GroupEmitter, person: Person) -> Group {
|
||||
Group {
|
||||
emit: emit,
|
||||
person: person,
|
||||
|
@ -32,7 +32,7 @@ pub struct InnerObject {
|
|||
}
|
||||
|
||||
impl InnerObjectTrait for InnerObject {
|
||||
fn create(emit: InnerObjectEmitter) -> InnerObject {
|
||||
fn new(emit: InnerObjectEmitter) -> InnerObject {
|
||||
InnerObject {
|
||||
emit: emit,
|
||||
description: String::new(),
|
||||
|
@ -56,7 +56,7 @@ pub struct Person {
|
|||
}
|
||||
|
||||
impl PersonTrait for Person {
|
||||
fn create(emit: PersonEmitter, object: InnerObject) -> Person {
|
||||
fn new(emit: PersonEmitter, object: InnerObject) -> Person {
|
||||
Person {
|
||||
emit: emit,
|
||||
object: object,
|
||||
|
|
|
@ -63,7 +63,7 @@ impl GroupEmitter {
|
|||
}
|
||||
|
||||
pub trait GroupTrait {
|
||||
fn create(emit: GroupEmitter,
|
||||
fn new(emit: GroupEmitter,
|
||||
person: Person) -> Self;
|
||||
fn emit(&self) -> &GroupEmitter;
|
||||
fn person(&self) -> &Person;
|
||||
|
@ -81,16 +81,16 @@ pub extern "C" fn group_new(
|
|||
qobject: Arc::new(Mutex::new(object)),
|
||||
description_changed: description_changed,
|
||||
};
|
||||
let d_object = InnerObject::create(object_emit);
|
||||
let d_object = InnerObject::new(object_emit);
|
||||
let person_emit = PersonEmitter {
|
||||
qobject: Arc::new(Mutex::new(person)),
|
||||
};
|
||||
let d_person = Person::create(person_emit,
|
||||
let d_person = Person::new(person_emit,
|
||||
d_object);
|
||||
let group_emit = GroupEmitter {
|
||||
qobject: Arc::new(Mutex::new(group)),
|
||||
};
|
||||
let d_group = Group::create(group_emit,
|
||||
let d_group = Group::new(group_emit,
|
||||
d_person);
|
||||
Box::into_raw(Box::new(d_group))
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ impl InnerObjectEmitter {
|
|||
}
|
||||
|
||||
pub trait InnerObjectTrait {
|
||||
fn create(emit: InnerObjectEmitter) -> Self;
|
||||
fn new(emit: InnerObjectEmitter) -> Self;
|
||||
fn emit(&self) -> &InnerObjectEmitter;
|
||||
fn description(&self) -> &str;
|
||||
fn set_description(&mut self, value: String);
|
||||
|
@ -143,7 +143,7 @@ pub extern "C" fn inner_object_new(
|
|||
qobject: Arc::new(Mutex::new(inner_object)),
|
||||
description_changed: description_changed,
|
||||
};
|
||||
let d_inner_object = InnerObject::create(inner_object_emit);
|
||||
let d_inner_object = InnerObject::new(inner_object_emit);
|
||||
Box::into_raw(Box::new(d_inner_object))
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ impl PersonEmitter {
|
|||
}
|
||||
|
||||
pub trait PersonTrait {
|
||||
fn create(emit: PersonEmitter,
|
||||
fn new(emit: PersonEmitter,
|
||||
object: InnerObject) -> Self;
|
||||
fn emit(&self) -> &PersonEmitter;
|
||||
fn object(&self) -> &InnerObject;
|
||||
|
@ -200,11 +200,11 @@ pub extern "C" fn person_new(
|
|||
qobject: Arc::new(Mutex::new(object)),
|
||||
description_changed: description_changed,
|
||||
};
|
||||
let d_object = InnerObject::create(object_emit);
|
||||
let d_object = InnerObject::new(object_emit);
|
||||
let person_emit = PersonEmitter {
|
||||
qobject: Arc::new(Mutex::new(person)),
|
||||
};
|
||||
let d_person = Person::create(person_emit,
|
||||
let d_person = Person::new(person_emit,
|
||||
d_object);
|
||||
Box::into_raw(Box::new(d_person))
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ pub struct Persons {
|
|||
}
|
||||
|
||||
impl PersonsTrait for Persons {
|
||||
fn create(emit: PersonsEmitter, model: PersonsTree) -> Persons {
|
||||
fn new(emit: PersonsEmitter, model: PersonsTree) -> Persons {
|
||||
Persons {
|
||||
emit: emit,
|
||||
model: model,
|
||||
|
|
|
@ -144,7 +144,7 @@ impl PersonsTree {
|
|||
}
|
||||
|
||||
pub trait PersonsTrait {
|
||||
fn create(emit: PersonsEmitter, model: PersonsTree) -> Self;
|
||||
fn new(emit: PersonsEmitter, model: PersonsTree) -> Self;
|
||||
fn emit(&self) -> &PersonsEmitter;
|
||||
fn row_count(&self, Option<usize>) -> usize;
|
||||
fn can_fetch_more(&self, Option<usize>) -> bool {
|
||||
|
@ -185,7 +185,7 @@ pub extern "C" fn persons_new(
|
|||
begin_remove_rows: persons_begin_remove_rows,
|
||||
end_remove_rows: persons_end_remove_rows,
|
||||
};
|
||||
let d_persons = Persons::create(persons_emit, model);
|
||||
let d_persons = Persons::new(persons_emit, model);
|
||||
Box::into_raw(Box::new(d_persons))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue