Skip to content

Avi-D-coder/locked-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Allows you to pass a lock with it's resource.

use locked_resource::{LockedResource, WithLock};
use std::io::{stdin, BufRead, Stdin, StdinLock};

fn use_stdin<'l>(
    mut locked_stdin: LockedResource<Stdin, StdinLock<'l>>,
) -> LockedResource<Stdin, StdinLock<'l>> {
    let mut line = String::new();
    locked_stdin.read_line(&mut line).unwrap();
    locked_stdin
}

fn main() {
    let mut locked_stdin = stdin().with_lock();

    let mut line = String::new();
    locked_stdin.read_line(&mut line).unwrap();
    let locked_resource = use_stdin(locked_stdin);

    let mut line = String::new();
    locked_stdin.read_line(&mut line).unwrap();
}

TODO

  • Implement for Stdout
  • Implement for Stderr
  • etc..

About

Allows you to pass a lock (StdinLock) with it's resource (Stdin).

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages