Skip to content

Commit

Permalink
Take FnOnce() instead of Fn() in terminal::with_*()
Browse files Browse the repository at this point in the history
  • Loading branch information
nabijaczleweli committed Oct 11, 2016
1 parent f2c5db5 commit 20a0736
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/terminal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn set_foreground(color: Color) {
}

/// Sets the foreground color before calling the function and resets it afterwards.
pub fn with_foreground<F: Fn()>(color: Color, callback: F) {
pub fn with_foreground<F: FnOnce()>(color: Color, callback: F) {
let current = ffi::state_color(ffi::TK_COLOR);
set_foreground(color);
callback();
Expand All @@ -100,7 +100,7 @@ pub fn set_background(color: Color) {
}

/// Sets the background color before calling the function and resets it afterwards.
pub fn with_background<F: Fn()>(color: Color, callback: F) {
pub fn with_background<F: FnOnce()>(color: Color, callback: F) {
let current = ffi::state_color(ffi::TK_BKCOLOR);
set_background(color);
callback();
Expand All @@ -116,7 +116,7 @@ pub fn set_colors(fg: Color, bg: Color) {
}

/// Sets the foreground and background color before calling the function and resets them afterwards.
pub fn with_colors<F: Fn()>(fg: Color, bg: Color, callback: F) {
pub fn with_colors<F: FnOnce()>(fg: Color, bg: Color, callback: F) {
with_foreground(fg, ||
with_background(bg, ||
callback()
Expand Down

0 comments on commit 20a0736

Please sign in to comment.