Skip to content

Are Handlers intended to be returned? #411

Answered by XAMPPRocky
mschuchard asked this question in Q&A
Discussion options

You must be logged in to vote

Well I'm not sure about passing the function as a pointer, but I would probably use closures instead. If you know what the return type will be, you can replace I with that type.

pub fn new_issues<I, F>(
    pat: Option<String>, 
    owner: &str, 
    repo: &str,
    customise: impl FnOnce(octocrab::issues::IssueHandler) -> F
) -> Result<I, ()>
    where F: Future<Output = Result<I, ()>>
{
    // instantiate client
    let client = match pat {
        Some(pat) => octocrab::Octocrab::builder()
        .personal_token(pat)
        .build()
        .unwrap(),
        None => octocrab::Octocrab::default(),
    };
    // initalize and return issues
    return (customise)(client.issues(owner, repo

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@XAMPPRocky
Comment options

Answer selected by mschuchard
@mschuchard
Comment options

@XAMPPRocky
Comment options

@mschuchard
Comment options

@XAMPPRocky
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #410 on July 13, 2023 16:15.