Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blanket implementations for usual I/O structures #46

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nomius10
Copy link

@nomius10 nomius10 commented Mar 17, 2021

My attempt at implementing #20

Python I/O objects usually have a isatty() method:

file = open("foo.txt", "wb")
ret = file.isatty()

This PR mirrors that functionality by adding a trait containing that function, along with blanket implementations for AsRawFD (unix) and AsRawHandle+AsRawSocket (windows). This would allow the following:

use atty::IsATTY;

fn main() {
    let file = std::fs::File::open("foo.txt").unwrap();
    let ret = file.isatty();
}

As far as I can tell, the names I've picked for the trait and method might break naming conventions. I'd appreciate some input on whether the naming should be changed.

Other notes:

  • I had to remove nostd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant