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.
This commit is contained in:
Felix Krull 2019-05-18 14:48:11 +02:00 committed by Colin Walters
parent 8bfefa2b14
commit 8561eaaa8c
2 changed files with 6 additions and 2 deletions

View File

@ -917,7 +917,7 @@ indicating a ref name which is not globally unique.</doc>
@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.</doc>
<return-value transfer-ownership="full">
<return-value transfer-ownership="full" nullable="1">
<doc xml:space="preserve">a new #OstreeCollectionRef</doc>
<type name="CollectionRef" c:type="OstreeCollectionRef*"/>
</return-value>

View File

@ -20,7 +20,8 @@ glib_wrapper! {
impl CollectionRef {
#[cfg(any(feature = "v2018_6", feature = "dox"))]
pub fn new<'a, P: Into<Option<&'a str>>>(collection_id: P, ref_name: &str) -> CollectionRef {
// CHANGE: return type CollectionRef to Option<CollectionRef>
pub fn new<'a, P: Into<Option<&'a str>>>(collection_id: P, ref_name: &str) -> Option<CollectionRef> {
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;