Skip to content

Commit 15a10f0

Browse files
committed
Rustfmt
1 parent ec69a35 commit 15a10f0

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

.rustfmt.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
write_mode = "Overwrite"
21
hard_tabs = true

src/playlist.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ use core::clone::Clone;
22
use core::ops::Deref;
33
use diesel;
44
use diesel::prelude::*;
5-
use diesel::BelongingToDsl;
65
use diesel::types::*;
6+
use diesel::BelongingToDsl;
77
use std::path::Path;
88

99
#[cfg(test)]
1010
use db;
1111
use db::ConnectionSource;
12-
use db::{playlists, playlist_songs, users};
12+
use db::{playlist_songs, playlists, users};
13+
use errors::*;
1314
use index::{self, Song};
1415
use vfs::VFSSource;
15-
use errors::*;
1616

1717
#[derive(Insertable)]
18-
#[table_name="playlists"]
18+
#[table_name = "playlists"]
1919
struct NewPlaylist {
2020
name: String,
2121
owner: i32,
@@ -27,29 +27,30 @@ pub struct User {
2727
}
2828

2929
#[derive(Identifiable, Queryable, Associations)]
30-
#[belongs_to(User, foreign_key="owner")]
30+
#[belongs_to(User, foreign_key = "owner")]
3131
pub struct Playlist {
3232
id: i32,
3333
owner: i32,
3434
}
3535

3636
#[derive(Identifiable, Queryable, Associations)]
37-
#[belongs_to(Playlist, foreign_key="playlist")]
37+
#[belongs_to(Playlist, foreign_key = "playlist")]
3838
pub struct PlaylistSong {
3939
id: i32,
4040
playlist: i32,
4141
}
4242

4343
#[derive(Insertable)]
44-
#[table_name="playlist_songs"]
44+
#[table_name = "playlist_songs"]
4545
pub struct NewPlaylistSong {
4646
playlist: i32,
4747
path: String,
4848
ordering: i32,
4949
}
5050

5151
pub fn list_playlists<T>(owner: &str, db: &T) -> Result<Vec<String>>
52-
where T: ConnectionSource + VFSSource
52+
where
53+
T: ConnectionSource + VFSSource,
5354
{
5455
let connection = db.get_connection();
5556

@@ -71,12 +72,9 @@ pub fn list_playlists<T>(owner: &str, db: &T) -> Result<Vec<String>>
7172
}
7273
}
7374

74-
pub fn save_playlist<T>(playlist_name: &str,
75-
owner: &str,
76-
content: &[String],
77-
db: &T)
78-
-> Result<()>
79-
where T: ConnectionSource + VFSSource
75+
pub fn save_playlist<T>(playlist_name: &str, owner: &str, content: &[String], db: &T) -> Result<()>
76+
where
77+
T: ConnectionSource + VFSSource,
8078
{
8179
let user: User;
8280
let new_playlist: NewPlaylist;
@@ -119,14 +117,16 @@ pub fn save_playlist<T>(playlist_name: &str,
119117

120118
for (i, path) in content.iter().enumerate() {
121119
let virtual_path = Path::new(&path);
122-
if let Some(real_path) = vfs.virtual_to_real(virtual_path)
123-
.ok()
124-
.and_then(|p| p.to_str().map(|s| s.to_owned())) {
120+
if let Some(real_path) = vfs
121+
.virtual_to_real(virtual_path)
122+
.ok()
123+
.and_then(|p| p.to_str().map(|s| s.to_owned()))
124+
{
125125
new_songs.push(NewPlaylistSong {
126-
playlist: playlist.id,
127-
path: real_path,
128-
ordering: i as i32,
129-
});
126+
playlist: playlist.id,
127+
path: real_path,
128+
ordering: i as i32,
129+
});
130130
}
131131
}
132132

@@ -151,7 +151,8 @@ pub fn save_playlist<T>(playlist_name: &str,
151151
}
152152

153153
pub fn read_playlist<T>(playlist_name: &str, owner: &str, db: &T) -> Result<Vec<Song>>
154-
where T: ConnectionSource + VFSSource
154+
where
155+
T: ConnectionSource + VFSSource,
155156
{
156157
let vfs = db.get_vfs()?;
157158
let songs: Vec<Song>;
@@ -201,7 +202,8 @@ pub fn read_playlist<T>(playlist_name: &str, owner: &str, db: &T) -> Result<Vec<
201202
}
202203

203204
pub fn delete_playlist<T>(playlist_name: &str, owner: &str, db: &T) -> Result<()>
204-
where T: ConnectionSource + VFSSource
205+
where
206+
T: ConnectionSource + VFSSource,
205207
{
206208
let connection = db.get_connection();
207209

src/serve.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,7 @@ impl PartialFile {
8484
Range: Into<PartialFileRange>,
8585
{
8686
let range = range.into();
87-
PartialFile {
88-
file,
89-
range,
90-
}
87+
PartialFile { file, range }
9188
}
9289

9390
pub fn from_path<P: AsRef<Path>, Range>(path: P, range: Range) -> Result<PartialFile, io::Error>

0 commit comments

Comments
 (0)