Last active
December 15, 2020 19:02
-
-
Save Alxandr/70a4e3507f309b5006c0ef6da6c1a5e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::tag::TagLookup; | |
use git2::Repository; | |
pub struct Context { | |
// NOTE: This lifetime is fake | |
tags: TagLookup<'static>, | |
// IMPORTANT: this has to be last to be dropped last | |
repo: Box<Repository>, | |
} | |
impl Context { | |
fn create(repo: Repository) -> Result<Context, git2::Error> { | |
let repo = Box::new(repo); | |
let tags: TagLookup<'static> = { | |
let repo = &*repo; | |
let lookup = TagLookup::create(&repo, None)?; | |
unsafe { std::intrinsics::transmute(lookup) } | |
}; | |
let context = unsafe { Context { repo, tags } }; | |
Ok(context) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment