Skip to content

Commit a41755b

Browse files
authored
Merge pull request #1 from Jake-Shadle/init_fix
Remove call to Windows-only fn on non-Windows
2 parents 51e9917 + feeace7 commit a41755b

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: rust
2+
3+
addons:
4+
apt:
5+
packages:
6+
- libcurl4-openssl-dev
7+
- libelf-dev
8+
- libdw-dev
9+
10+
rust:
11+
- beta
12+
- stable
13+
14+
# load travis-cargo
15+
before_script:
16+
- |
17+
pip install 'travis-cargo<0.2' --user &&
18+
export PATH=$HOME/.local/bin:$PATH
19+
20+
script:
21+
- |
22+
travis-cargo build

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- Fix build for non-Windows platforms
810

911
## [v0.2.0] - 2018-06-05
1012
Removed `init()`. Instead, ANSI is automatically enabled the first time an ANSI string is crated.

src/lib.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate itertools;
55
use ansi_term::{ANSIGenericString, Colour};
66
use difference::{Changeset, Difference};
77
use itertools::Itertools;
8-
use std::{fmt, sync::Once};
8+
use std::fmt;
99

1010
fn red(s: &str) -> ANSIGenericString<str> {
1111
Colour::Red.paint(s)
@@ -25,12 +25,18 @@ static NL_LEFT: &str = "\n<";
2525
static RIGHT: &str = ">";
2626
static NL_RIGHT: &str = "\n>";
2727

28+
#[cfg(windows)]
29+
#[inline(always)]
30+
fn enable_ansi() {
31+
use std::sync::Once;
32+
33+
static ONCE: Once = Once::new();
34+
ONCE.call_once(|| {ansi_term::enable_ansi_support().ok();});
35+
}
36+
37+
#[cfg(not(windows))]
2838
#[inline(always)]
2939
fn enable_ansi() {
30-
if cfg!(windows) {
31-
static ONCE: Once = Once::new();
32-
ONCE.call_once(|| {ansi_term::enable_ansi_support().ok();});
33-
}
3440
}
3541

3642
#[derive(Copy, Clone, Debug)]

0 commit comments

Comments
 (0)