diff options
author | Ben S <ogham@bsago.me> | 2014-11-24 02:16:28 +0000 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2014-11-24 02:16:28 +0000 |
commit | 8e455f9390c9978e875be48a9a70451d61f1d2c5 (patch) | |
tree | b71b6e79509112ef0cfabe4dc3161af696c72805 /src/term.rs | |
parent | 5b7124bb71aa5f7052af3f900c54913a3554c1c5 (diff) |
Optimise unsafe usage
Diffstat (limited to 'src/term.rs')
-rw-r--r-- | src/term.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/term.rs b/src/term.rs index 0a3e0c4..6b76016 100644 --- a/src/term.rs +++ b/src/term.rs @@ -30,17 +30,15 @@ mod c { pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; } - pub fn dimensions() -> winsize { - unsafe { - let mut window: winsize = zeroed(); - ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut window as *mut winsize); - window - } + pub unsafe fn dimensions() -> winsize { + let mut window: winsize = zeroed(); + ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut window as *mut winsize); + window } } pub fn dimensions() -> Option<(uint, uint)> { - let w = c::dimensions(); + let w = unsafe { c::dimensions() }; // If either of the dimensions is 0 then the command failed, // usually because output isn't to a terminal (instead to a file |