Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.

Commit 86e9de0

Browse files
authored
command line options now use OsStrings (#8)
1 parent 1f0334f commit 86e9de0

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

gio-subclass/src/application.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ use std::fmt;
1111
use std::mem;
1212
use std::ops::Deref;
1313
use std::ptr;
14+
use std::ffi::OsString;
1415

1516
use gobject_subclass::anyimpl::*;
1617
use gobject_subclass::object::*;
1718

1819
pub struct ArgumentList {
1920
pub(crate) ptr: *mut *mut *mut libc::c_char,
20-
items: Vec<String>,
21+
items: Vec<OsString>,
2122
}
2223

2324
impl ArgumentList {
@@ -55,7 +56,7 @@ impl ArgumentList {
5556
}
5657

5758
impl Deref for ArgumentList {
58-
type Target = [String];
59+
type Target = [OsString];
5960

6061
fn deref(&self) -> &Self::Target {
6162
self.items.as_slice()
@@ -68,8 +69,8 @@ impl fmt::Debug for ArgumentList {
6869
}
6970
}
7071

71-
impl convert::Into<Vec<String>> for ArgumentList {
72-
fn into(self) -> Vec<String> {
72+
impl convert::Into<Vec<OsString>> for ArgumentList {
73+
fn into(self) -> Vec<OsString> {
7374
self.items.clone()
7475
}
7576
}

gio-subclass/tests/simple_application.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ mod imp {
6868
let mut rm = Vec::new();
6969

7070
for (i, line) in arguments.iter().enumerate() {
71-
if line.starts_with("--local-") {
71+
// TODO: we need https://github.com/rust-lang/rust/issues/49802
72+
let l = line.clone().into_string().unwrap();
73+
if l.starts_with("--local-") {
7274
rm.push(i)
7375
}
7476
}
@@ -90,7 +92,9 @@ mod imp {
9092
let arguments = cmd_line.get_arguments();
9193

9294
for arg in arguments {
93-
assert!(!arg.starts_with("--local-"))
95+
// TODO: we need https://github.com/rust-lang/rust/issues/49802
96+
let a = arg.into_string().unwrap();
97+
assert!(!a.starts_with("--local-"))
9498
}
9599

96100
return EXIT_STATUS;

0 commit comments

Comments
 (0)