Skip to content

Commit 78f29ee

Browse files
committed
cargo fmt
1 parent fb3ab3e commit 78f29ee

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ pub use crate::config::{AccessMode, Config, DefaultNullOrder, DefaultOrder};
7878
pub use crate::error::Error;
7979
pub use crate::ffi::ErrorCode;
8080
pub use crate::params::{params_from_iter, Params, ParamsFromIter};
81+
pub use crate::r2d2::DuckdbConnectionManager;
8182
pub use crate::row::{AndThenRows, Map, MappedRows, Row, RowIndex, Rows};
8283
pub use crate::statement::Statement;
8384
pub use crate::transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior};
8485
pub use crate::types::ToSql;
85-
pub use crate::r2d2::DuckdbConnectionManager;
8686

8787
#[macro_use]
8888
mod error;
@@ -94,11 +94,11 @@ mod config;
9494
mod inner_connection;
9595
mod params;
9696
mod pragma;
97+
mod r2d2;
9798
mod raw_statement;
9899
mod row;
99100
mod statement;
100101
mod transaction;
101-
mod r2d2;
102102

103103
pub mod types;
104104

src/r2d2.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
//! ```rust,no_run
1111
//! extern crate r2d2;
1212
//! extern crate duckdb;
13-
//!
13+
//!
1414
//!
1515
//! use std::thread;
1616
//! use duckdb::{DuckdbConnectionManager, params};
17-
//!
17+
//!
1818
//!
1919
//! fn main() {
2020
//! let manager = DuckdbConnectionManager::file("file.db").unwrap();
@@ -40,16 +40,18 @@
4040
//! .unwrap()
4141
//! }
4242
//! ```
43-
use std::{path::Path, sync::{Mutex, Arc}};
44-
use crate::{Result, Connection, Error, Config};
43+
use crate::{Config, Connection, Error, Result};
44+
use std::{
45+
path::Path,
46+
sync::{Arc, Mutex},
47+
};
4548

4649
/// An `r2d2::ManageConnection` for `duckdb::Connection`s.
4750
pub struct DuckdbConnectionManager {
4851
connection: Arc<Mutex<Connection>>,
4952
}
5053

5154
impl DuckdbConnectionManager {
52-
5355
/// Creates a new `DuckdbConnectionManager` from file.
5456
pub fn file<P: AsRef<Path>>(path: P) -> Result<Self> {
5557
Ok(Self {
@@ -96,57 +98,55 @@ impl r2d2::ManageConnection for DuckdbConnectionManager {
9698
}
9799
}
98100

99-
100101
#[cfg(test)]
101102
mod test {
102103
extern crate r2d2;
103104
use super::*;
104-
use crate::Result;
105105
use crate::types::Value;
106+
use crate::Result;
106107
use std::{sync::mpsc, thread};
107108

108109
use tempdir::TempDir;
109110

110-
111111
#[test]
112-
fn test_basic() -> Result<()>{
112+
fn test_basic() -> Result<()> {
113113
let manager = DuckdbConnectionManager::file("file.db")?;
114114
let pool = r2d2::Pool::builder().max_size(2).build(manager).unwrap();
115-
115+
116116
let (s1, r1) = mpsc::channel();
117117
let (s2, r2) = mpsc::channel();
118-
118+
119119
let pool1 = pool.clone();
120120
let t1 = thread::spawn(move || {
121121
let conn = pool1.get().unwrap();
122122
s1.send(()).unwrap();
123123
r2.recv().unwrap();
124124
drop(conn);
125125
});
126-
126+
127127
let pool2 = pool.clone();
128128
let t2 = thread::spawn(move || {
129129
let conn = pool2.get().unwrap();
130130
s2.send(()).unwrap();
131131
r1.recv().unwrap();
132132
drop(conn);
133133
});
134-
134+
135135
t1.join().unwrap();
136136
t2.join().unwrap();
137-
137+
138138
pool.get().unwrap();
139139
Ok(())
140140
}
141-
141+
142142
#[test]
143-
fn test_file() -> Result<()>{
143+
fn test_file() -> Result<()> {
144144
let manager = DuckdbConnectionManager::file("file.db")?;
145145
let pool = r2d2::Pool::builder().max_size(2).build(manager).unwrap();
146-
146+
147147
let (s1, r1) = mpsc::channel();
148148
let (s2, r2) = mpsc::channel();
149-
149+
150150
let pool1 = pool.clone();
151151
let t1 = thread::spawn(move || {
152152
let conn = pool1.get().unwrap();
@@ -155,35 +155,35 @@ mod test {
155155
r2.recv().unwrap();
156156
drop(conn1);
157157
});
158-
158+
159159
let pool2 = pool.clone();
160160
let t2 = thread::spawn(move || {
161161
let conn = pool2.get().unwrap();
162162
s2.send(()).unwrap();
163163
r1.recv().unwrap();
164164
drop(conn);
165165
});
166-
166+
167167
t1.join().unwrap();
168168
t2.join().unwrap();
169-
169+
170170
pool.get().unwrap();
171171
Ok(())
172172
}
173-
173+
174174
#[test]
175-
fn test_is_valid() -> Result<()>{
175+
fn test_is_valid() -> Result<()> {
176176
let manager = DuckdbConnectionManager::file("file.db")?;
177177
let pool = r2d2::Pool::builder()
178178
.max_size(1)
179179
.test_on_check_out(true)
180180
.build(manager)
181181
.unwrap();
182-
182+
183183
pool.get().unwrap();
184184
Ok(())
185185
}
186-
186+
187187
#[test]
188188
fn test_error_handling() -> Result<()> {
189189
//! We specify a directory as a database. This is bound to fail.
@@ -192,17 +192,17 @@ mod test {
192192
assert!(DuckdbConnectionManager::file(dirpath).is_err());
193193
Ok(())
194194
}
195-
195+
196196
#[test]
197197
fn test_with_flags() -> Result<()> {
198198
let config = Config::default()
199-
.access_mode(crate::AccessMode::ReadWrite)?
200-
.default_null_order(crate::DefaultNullOrder::NullsLast)?
201-
.default_order(crate::DefaultOrder::Desc)?
202-
.enable_external_access(true)?
203-
.enable_object_cache(false)?
204-
.max_memory("2GB")?
205-
.threads(4)?;
199+
.access_mode(crate::AccessMode::ReadWrite)?
200+
.default_null_order(crate::DefaultNullOrder::NullsLast)?
201+
.default_order(crate::DefaultOrder::Desc)?
202+
.enable_external_access(true)?
203+
.enable_object_cache(false)?
204+
.max_memory("2GB")?
205+
.threads(4)?;
206206
let manager = DuckdbConnectionManager::file_with_flags("file.db", config)?;
207207
let pool = r2d2::Pool::builder().max_size(2).build(manager).unwrap();
208208
let conn = pool.get().unwrap();
@@ -228,4 +228,4 @@ mod test {
228228

229229
Ok(())
230230
}
231-
}
231+
}

0 commit comments

Comments
 (0)