Skip to content

Commit

Permalink
Merge pull request #1380 from sdroege/object-new-panic
Browse files Browse the repository at this point in the history
Update for `Object::new()` panicking instead of returning a `Result`
  • Loading branch information
sdroege committed Oct 7, 2022
2 parents 0c1af7d + 1919a37 commit b5068ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/codegen/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,6 @@ pub fn declare_default_from_new(
"impl Default for {0} {{
fn default() -> Self {{
glib::object::Object::new::<Self>(&[])
.expect(\"Can't construct {0} object with default parameters\")
}}
}}",
name
Expand Down
10 changes: 4 additions & 6 deletions src/codegen/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,18 +486,16 @@ impl {name}Builder {{
if let Some(code) = analysis.builder_postprocess.as_ref() {
writeln!(
w,
r#" let ret = {}::Object::new::<{}>(&properties)
.expect("Failed to create an instance of {}");"#,
glib_crate_name, analysis.name, analysis.name,
r#" let ret = {}::Object::new::<{}>(&properties);"#,
glib_crate_name, analysis.name,
)?;
writeln!(w, " {{\n {}\n }}", code)?;
writeln!(w, " ret\n }}")?;
} else {
writeln!(
w,
r#" {}::Object::new::<{}>(&properties)
.expect("Failed to create an instance of {}")"#,
glib_crate_name, analysis.name, analysis.name,
r#" {}::Object::new::<{}>(&properties)"#,
glib_crate_name, analysis.name,
)?;
writeln!(w, "\n }}")?;
}
Expand Down

0 comments on commit b5068ed

Please sign in to comment.