Skip to content

Commit bd6b4b5

Browse files
authored
Merge pull request #11 from sfackler/no-postgres-dep
Cleanup
2 parents 245ef9e + a63729b commit bd6b4b5

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

‎.travis.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ language: rust
22
rust:
33
- nightly
44
- beta
5-
- 1.20.0
5+
- 1.26.0
66
addons:
77
postgresql: 9.4
88
script:
99
- cargo test
10+
- cargo test --features "with-time with-chrono"

‎Cargo.toml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ description = "Range support for rust-postgres"
77
repository = "https://github.com/sfackler/rust-postgres-range"
88
documentation = "https://sfackler.github.io/rust-postgres-range/doc/v0.9.0/postgres_range"
99

10+
[features]
11+
with-time = ["time", "postgres-shared/with-time"]
12+
with-chrono = ["chrono", "postgres-shared/with-chrono"]
13+
1014
[dependencies]
11-
time = "0.1"
12-
postgres = "0.15"
15+
time ={version = "0.1", optional = true }
1316
postgres-protocol = "0.3"
14-
chrono = "0.4.0"
15-
postgres-shared = {version = "0.4.0", features = ["with-chrono"] }
17+
chrono = {version = "0.4.0", optional = true }
18+
postgres-shared = "0.4.0"
1619

1720
[dev-dependencies]
1821
postgres ={version = "0.15", features = ["with-time"] }

‎src/impls.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::error::Error;
2-
usepostgres::types::{FromSql,IsNull,Kind,ToSql,Type};
2+
usepostgres_shared::types::{FromSql,IsNull,Kind,ToSql,Type};
33
use postgres_protocol::{selfas protocol, types};
44

55
use{BoundSided,BoundType,Normalizable,Range,RangeBound};
@@ -116,6 +116,7 @@ mod test{
116116

117117
use postgres::{Connection,TlsMode};
118118
use postgres::types::{FromSql,ToSql};
119+
#[cfg(feature = "with-time")]
119120
use time::{self,Timespec};
120121

121122
macro_rules! test_range {
@@ -163,6 +164,7 @@ mod test{
163164
test_range!("INT8RANGE",i64,100i64,"100",200i64,"200")
164165
}
165166

167+
#[cfg(feature = "with-time")]
166168
fntest_timespec_range_params(sql_type:&str){
167169
fnt(time:&str) -> Timespec{
168170
time::strptime(time,"%Y-%m-%d").unwrap().to_timespec()
@@ -173,11 +175,13 @@ mod test{
173175
}
174176

175177
#[test]
178+
#[cfg(feature = "with-time")]
176179
fntest_tsrange_params(){
177180
test_timespec_range_params("TSRANGE");
178181
}
179182

180183
#[test]
184+
#[cfg(feature = "with-time")]
181185
fntest_tstzrange_params(){
182186
test_timespec_range_params("TSTZRANGE");
183187
}

‎src/lib.rs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
//! Types dealing with ranges of values
22
#![doc(html_root_url = "https://sfackler.github.io/rust-postgres-range/doc/v0.8.2")]
33

4-
#[macro_use(to_sql_checked)]
5-
externcrate postgres;
64
externcrate postgres_protocol;
5+
#[macro_use(to_sql_checked)]
76
externcrate postgres_shared;
7+
8+
#[cfg(feature = "with-time")]
89
externcrate time;
10+
#[cfg(feature = "with-chrono")]
911
externcrate chrono;
10-
use chrono::{DateTime,TimeZone};
1112

13+
#[cfg(test)]
14+
externcrate postgres;
15+
16+
#[cfg(feature = "with-chrono")]
17+
use chrono::{DateTime,TimeZone};
1218
use std::cmp::Ordering;
1319
use std::fmt;
1420
use std::i32;
1521
use std::i64;
1622
use std::marker::PhantomData;
17-
23+
#[cfg(feature = "with-time")]
1824
use time::Timespec;
1925

2026
useBoundSide::{Lower,Upper};
@@ -149,6 +155,7 @@ macro_rules! bounded_normalizable{
149155
bounded_normalizable!(i32);
150156
bounded_normalizable!(i64);
151157

158+
#[cfg(feature = "with-time")]
152159
implNormalizableforTimespec{
153160
fnnormalize<S>(bound:RangeBound<S,Timespec>) -> RangeBound<S,Timespec>
154161
where
@@ -158,7 +165,8 @@ impl Normalizable for Timespec{
158165
}
159166
}
160167

161-
impl<T>NormalizableforDateTime<T>
168+
#[cfg(feature = "with-chrono")]
169+
impl<T>NormalizableforDateTime<T>
162170
whereT:TimeZone{
163171
fnnormalize<S>(bound:RangeBound<S,DateTime<T>>) -> RangeBound<S,DateTime<T>>
164172
where

0 commit comments

Comments
(0)