From 8561eaaa8c2e67a43781b0e880f0c324741ee610 Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Sat, 18 May 2019 14:48:11 +0200 Subject: [PATCH] Fix return type for CollectionRef::new gir doesn't seem to generate this correctly. I have no clue why, there are certainly some functions where nullable=1 causes an Option return. --- rust-bindings/rust/gir-files/OSTree-1.0.gir | 2 +- .../rust/src/{collection_ref.rs => collection_ref/mod.rs} | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) rename rust-bindings/rust/src/{collection_ref.rs => collection_ref/mod.rs} (93%) diff --git a/rust-bindings/rust/gir-files/OSTree-1.0.gir b/rust-bindings/rust/gir-files/OSTree-1.0.gir index 33df3aa3..e144a270 100644 --- a/rust-bindings/rust/gir-files/OSTree-1.0.gir +++ b/rust-bindings/rust/gir-files/OSTree-1.0.gir @@ -917,7 +917,7 @@ indicating a ref name which is not globally unique. @collection_id is %NULL, this is equivalent to a plain ref name string (not a refspec; no remote name is included), which can be used for non-P2P operations. - + a new #OstreeCollectionRef diff --git a/rust-bindings/rust/src/collection_ref.rs b/rust-bindings/rust/src/collection_ref/mod.rs similarity index 93% rename from rust-bindings/rust/src/collection_ref.rs rename to rust-bindings/rust/src/collection_ref/mod.rs index 27374e37..dd93cb4f 100644 --- a/rust-bindings/rust/src/collection_ref.rs +++ b/rust-bindings/rust/src/collection_ref/mod.rs @@ -20,7 +20,8 @@ glib_wrapper! { impl CollectionRef { #[cfg(any(feature = "v2018_6", feature = "dox"))] - pub fn new<'a, P: Into>>(collection_id: P, ref_name: &str) -> CollectionRef { + // CHANGE: return type CollectionRef to Option + pub fn new<'a, P: Into>>(collection_id: P, ref_name: &str) -> Option { let collection_id = collection_id.into(); let collection_id = collection_id.to_glib_none(); unsafe { @@ -60,3 +61,6 @@ impl hash::Hash for CollectionRef { hash::Hash::hash(&self.hash(), state) } } + +#[cfg(test)] +mod tests;