From 8e455f9390c9978e875be48a9a70451d61f1d2c5 Mon Sep 17 00:00:00 2001 From: Ben S Date: Mon, 24 Nov 2014 02:16:28 +0000 Subject: [PATCH] Optimise unsafe usage --- src/term.rs | 12 +++++------- 1 file 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