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

command line options now use OsStrings #8

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions gio-subclass/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ use std::fmt;
use std::mem;
use std::ops::Deref;
use std::ptr;
use std::ffi::OsString;

use gobject_subclass::anyimpl::*;
use gobject_subclass::object::*;

pub struct ArgumentList {
pub(crate) ptr: *mut *mut *mut libc::c_char,
items: Vec<String>,
items: Vec<OsString>,
}

impl ArgumentList {
Expand Down Expand Up @@ -55,7 +56,7 @@ impl ArgumentList {
}

impl Deref for ArgumentList {
type Target = [String];
type Target = [OsString];

fn deref(&self) -> &Self::Target {
self.items.as_slice()
Expand All @@ -68,8 +69,8 @@ impl fmt::Debug for ArgumentList {
}
}

impl convert::Into<Vec<String>> for ArgumentList {
fn into(self) -> Vec<String> {
impl convert::Into<Vec<OsString>> for ArgumentList {
fn into(self) -> Vec<OsString> {
self.items.clone()
}
}
Expand Down
8 changes: 6 additions & 2 deletions gio-subclass/tests/simple_application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ mod imp {
let mut rm = Vec::new();

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

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

return EXIT_STATUS;
Expand Down