Skip to content

PollFd::new requires too restrictive lifetime #2118

@MaxVerevkin

Description

@MaxVerevkin

I was trying to do

if let Some(cmd_fd) = state.status_cmd_fd() {
    fds.push(PollFd::new(&cmd_fd, PollFlags::POLLIN));
}

where status_cmd_fd() returns Option<BorrowedFd<'_>>. This code does not compile because the reference &cmd_fd does not live long enough, but the lifetime of the reference should be irrelevant.


Current signature of PollFd::new is

pub fn new<Fd: AsFd>(fd: &'fd Fd, events: PollFlags) -> PollFd<'fd>

I think it should probably be

pub fn new<Fd: AsFd + 'fd>(fd: Fd, events: PollFlags) -> PollFd<'fd>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions