Skip to content

Commit 979e287

Browse files
authored
Don't pass AsRef<T> params by reference (shssoichiro#84)
1 parent 5834596 commit 979e287

File tree

6 files changed

+14
-20
lines changed

6 files changed

+14
-20
lines changed

examples/chapters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::env;
55
fn main() {
66
ffmpeg::init().unwrap();
77

8-
match ffmpeg::format::input(&env::args().nth(1).expect("missing input file name")) {
8+
match ffmpeg::format::input(env::args().nth(1).expect("missing input file name")) {
99
Ok(ictx) => {
1010
println!("Nb chapters: {}", ictx.nb_chapters());
1111

@@ -20,7 +20,7 @@ fn main() {
2020
}
2121
}
2222

23-
let mut octx = ffmpeg::format::output(&"test.mkv").expect("Couldn't open test file");
23+
let mut octx = ffmpeg::format::output("test.mkv").expect("Couldn't open test file");
2424

2525
for chapter in ictx.chapters() {
2626
let title = match chapter.metadata().get("title") {

examples/dump-frames.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::io::prelude::*;
1111
fn main() -> Result<(), ffmpeg::Error> {
1212
ffmpeg::init().unwrap();
1313

14-
if let Ok(mut ictx) = input(&env::args().nth(1).expect("Cannot open file.")) {
14+
if let Ok(mut ictx) = input(env::args().nth(1).expect("Cannot open file.")) {
1515
let input = ictx
1616
.streams()
1717
.best(Type::Video)

examples/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::env;
55
fn main() -> Result<(), ffmpeg::Error> {
66
ffmpeg::init().unwrap();
77

8-
match ffmpeg::format::input(&env::args().nth(1).expect("missing file")) {
8+
match ffmpeg::format::input(env::args().nth(1).expect("missing file")) {
99
Ok(context) => {
1010
for (k, v) in context.metadata().iter() {
1111
println!("{k}: {v}");

examples/transcode-audio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct Transcoder {
7272
fn transcoder<P: AsRef<Path>>(
7373
ictx: &mut format::context::Input,
7474
octx: &mut format::context::Output,
75-
path: &P,
75+
path: P,
7676
filter_spec: &str,
7777
) -> Result<Transcoder, ffmpeg::Error> {
7878
let input = ictx

src/format/format/output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Output {
5757
}
5858
}
5959

60-
pub fn codec<P: AsRef<Path>>(self, path: &P, kind: media::Type) -> codec::Id {
60+
pub fn codec<P: AsRef<Path>>(self, path: P, kind: media::Type) -> codec::Id {
6161
// XXX: use to_cstring when stable
6262
let path = CString::new(path.as_ref().to_str().unwrap()).unwrap();
6363

src/format/mod.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ pub fn license() -> &'static str {
3636
}
3737

3838
// XXX: use to_cstring when stable
39-
fn from_path<P: AsRef<Path>>(path: &P) -> CString {
39+
fn from_path<P: AsRef<Path>>(path: P) -> CString {
4040
CString::new(path.as_ref().as_os_str().to_str().unwrap()).unwrap()
4141
}
4242

43-
pub fn input<P: AsRef<Path>>(path: &P) -> Result<context::Input, Error> {
43+
pub fn input<P: AsRef<Path>>(path: P) -> Result<context::Input, Error> {
4444
unsafe {
4545
let mut ps = ptr::null_mut();
4646
let path = from_path(path);
@@ -60,7 +60,7 @@ pub fn input<P: AsRef<Path>>(path: &P) -> Result<context::Input, Error> {
6060
}
6161

6262
pub fn input_with_dictionary<P: AsRef<Path>>(
63-
path: &P,
63+
path: P,
6464
options: Dictionary,
6565
) -> Result<context::Input, Error> {
6666
unsafe {
@@ -85,10 +85,7 @@ pub fn input_with_dictionary<P: AsRef<Path>>(
8585
}
8686
}
8787

88-
pub fn input_with_interrupt<P: AsRef<Path>, F>(
89-
path: &P,
90-
closure: F,
91-
) -> Result<context::Input, Error>
88+
pub fn input_with_interrupt<P: AsRef<Path>, F>(path: P, closure: F) -> Result<context::Input, Error>
9289
where
9390
F: FnMut() -> bool,
9491
{
@@ -111,7 +108,7 @@ where
111108
}
112109
}
113110

114-
pub fn output<P: AsRef<Path>>(path: &P) -> Result<context::Output, Error> {
111+
pub fn output<P: AsRef<Path>>(path: P) -> Result<context::Output, Error> {
115112
unsafe {
116113
let mut ps = ptr::null_mut();
117114
let path = from_path(path);
@@ -127,10 +124,7 @@ pub fn output<P: AsRef<Path>>(path: &P) -> Result<context::Output, Error> {
127124
}
128125
}
129126

130-
pub fn output_with<P: AsRef<Path>>(
131-
path: &P,
132-
options: Dictionary,
133-
) -> Result<context::Output, Error> {
127+
pub fn output_with<P: AsRef<Path>>(path: P, options: Dictionary) -> Result<context::Output, Error> {
134128
unsafe {
135129
let mut ps = ptr::null_mut();
136130
let path = from_path(path);
@@ -159,7 +153,7 @@ pub fn output_with<P: AsRef<Path>>(
159153
}
160154
}
161155

162-
pub fn output_as<P: AsRef<Path>>(path: &P, format: &str) -> Result<context::Output, Error> {
156+
pub fn output_as<P: AsRef<Path>>(path: P, format: &str) -> Result<context::Output, Error> {
163157
unsafe {
164158
let mut ps = ptr::null_mut();
165159
let path = from_path(path);
@@ -182,7 +176,7 @@ pub fn output_as<P: AsRef<Path>>(path: &P, format: &str) -> Result<context::Outp
182176
}
183177

184178
pub fn output_as_with<P: AsRef<Path>>(
185-
path: &P,
179+
path: P,
186180
format: &str,
187181
options: Dictionary,
188182
) -> Result<context::Output, Error> {

0 commit comments

Comments
 (0)