Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
redox-os
ion
Commits
9931344b
Commit
9931344b
authored
Jun 25, 2019
by
AdminXVII
Browse files
Add documentation
parent
8916081d
Changes
44
Hide whitespace changes
Inline
Side-by-side
members/ranges/src/range.rs
View file @
9931344b
...
...
@@ -36,11 +36,19 @@ impl Range {
}
}
pub
fn
exclusive
(
start
:
Index
,
end
:
Index
)
->
Range
{
Range
{
start
,
end
,
inclusive
:
false
}
}
pub
fn
exclusive
(
start
:
Index
,
end
:
Index
)
->
Range
{
Range
{
start
,
end
,
inclusive
:
false
}
}
pub
fn
inclusive
(
start
:
Index
,
end
:
Index
)
->
Range
{
Range
{
start
,
end
,
inclusive
:
true
}
}
pub
fn
inclusive
(
start
:
Index
,
end
:
Index
)
->
Range
{
Range
{
start
,
end
,
inclusive
:
true
}
}
pub
fn
from
(
start
:
Index
)
->
Range
{
Range
{
start
,
end
:
Index
::
new
(
-
1
),
inclusive
:
true
}
}
pub
fn
from
(
start
:
Index
)
->
Range
{
Range
{
start
,
end
:
Index
::
new
(
-
1
),
inclusive
:
true
}
}
pub
fn
to
(
end
:
Index
)
->
Range
{
Range
{
start
:
Index
::
new
(
0
),
end
,
inclusive
:
false
}
}
pub
fn
to
(
end
:
Index
)
->
Range
{
Range
{
start
:
Index
::
new
(
0
),
end
,
inclusive
:
false
}
}
}
members/scopes-rs/src/lib.rs
View file @
9931344b
...
...
@@ -14,8 +14,8 @@ pub enum Namespace {
#[derive(Clone,
Debug)]
pub
struct
Scopes
<
K
:
Hash
+
Eq
,
V
>
{
flags
:
u8
,
scopes
:
Vec
<
Scope
<
K
,
V
>>
,
flags
:
u8
,
scopes
:
Vec
<
Scope
<
K
,
V
>>
,
current
:
usize
,
}
...
...
@@ -30,18 +30,22 @@ pub struct Scope<K: Hash + Eq, V> {
impl
<
K
:
Hash
+
Eq
,
V
>
Deref
for
Scope
<
K
,
V
>
{
type
Target
=
HashMap
<
K
,
V
>
;
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
self
.vars
}
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
self
.vars
}
}
impl
<
K
:
Hash
+
Eq
,
V
>
DerefMut
for
Scope
<
K
,
V
>
{
fn
deref_mut
(
&
mut
self
)
->
&
mut
Self
::
Target
{
&
mut
self
.vars
}
fn
deref_mut
(
&
mut
self
)
->
&
mut
Self
::
Target
{
&
mut
self
.vars
}
}
impl
<
K
:
Hash
+
Eq
,
V
:
Clone
>
Scopes
<
K
,
V
>
{
pub
fn
with_capacity
(
cap
:
usize
)
->
Self
{
Self
{
flags
:
0
,
scopes
:
vec!
[
Scope
{
vars
:
HashMap
::
with_capacity
(
cap
),
namespace
:
false
}],
flags
:
0
,
scopes
:
vec!
[
Scope
{
vars
:
HashMap
::
with_capacity
(
cap
),
namespace
:
false
}],
current
:
0
,
}
}
...
...
members/types-rs/src/lib.rs
View file @
9931344b
...
...
@@ -24,13 +24,17 @@ impl<T: Eq> Eq for Value<T> {}
// this one’s only special because of the lifetime parameter
impl
<
'a
,
T
>
From
<&
'a
str
>
for
Value
<
T
>
{
fn
from
(
string
:
&
'a
str
)
->
Self
{
Value
::
Str
(
string
.into
())
}
fn
from
(
string
:
&
'a
str
)
->
Self
{
Value
::
Str
(
string
.into
())
}
}
macro_rules!
value_from_type
{
(
$arg:ident
:
$from:ty
=>
$variant:ident
(
$inner:expr
))
=>
{
impl
<
T
>
From
<
$from
>
for
Value
<
T
>
{
fn
from
(
$arg
:
$from
)
->
Self
{
Value
::
$variant
(
$inner
)
}
fn
from
(
$arg
:
$from
)
->
Self
{
Value
::
$variant
(
$inner
)
}
}
};
}
...
...
members/types-rs/src/math.rs
View file @
9931344b
...
...
@@ -52,7 +52,9 @@ macro_rules! math {
impl
<
'a
,
T
>
$trait
<
Value
<
T
>>
for
&
'a
Value
<
T
>
{
type
Output
=
Result
<
Value
<
T
>
,
OpError
>
;
fn
$fn
(
self
,
rhs
:
Value
<
T
>
)
->
Self
::
Output
{
self
.
$fn
(
&
rhs
)
}
fn
$fn
(
self
,
rhs
:
Value
<
T
>
)
->
Self
::
Output
{
self
.
$fn
(
&
rhs
)
}
}
impl
<
'a
,
T
>
$trait
<
i128
>
for
&
'a
Value
<
T
>
{
...
...
members/types-rs/src/types.rs
View file @
9931344b
...
...
@@ -16,21 +16,29 @@ pub type Str = small::String;
pub
struct
Alias
(
pub
Str
);
impl
Alias
{
pub
fn
empty
()
->
Self
{
Alias
(
Str
::
with_capacity
(
1
))
}
pub
fn
empty
()
->
Self
{
Alias
(
Str
::
with_capacity
(
1
))
}
}
impl
Deref
for
Alias
{
type
Target
=
Str
;
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
self
.0
}
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
self
.0
}
}
impl
DerefMut
for
Alias
{
fn
deref_mut
(
&
mut
self
)
->
&
mut
Self
::
Target
{
&
mut
self
.0
}
fn
deref_mut
(
&
mut
self
)
->
&
mut
Self
::
Target
{
&
mut
self
.0
}
}
impl
Into
<
Str
>
for
Alias
{
fn
into
(
self
)
->
Str
{
self
.0
}
fn
into
(
self
)
->
Str
{
self
.0
}
}
impl
<
T
>
FromIterator
<
Value
<
T
>>
for
Value
<
T
>
{
...
...
src/binary/completer.rs
View file @
9931344b
...
...
@@ -8,7 +8,7 @@ use liner::{BasicCompleter, Completer, CursorPosition, Event, EventKind};
use
std
::{
env
,
iter
,
path
::
PathBuf
,
str
};
pub
struct
IonCompleter
<
'a
,
'b
>
{
shell
:
&
'b
Shell
<
'a
>
,
shell
:
&
'b
Shell
<
'a
>
,
history_completer
:
Option
<
BasicCompleter
>
,
}
...
...
@@ -30,7 +30,9 @@ fn escape(input: &str) -> String {
}
impl
<
'a
,
'b
>
IonCompleter
<
'a
,
'b
>
{
pub
fn
new
(
shell
:
&
'b
Shell
<
'a
>
)
->
Self
{
IonCompleter
{
shell
,
history_completer
:
None
}
}
pub
fn
new
(
shell
:
&
'b
Shell
<
'a
>
)
->
Self
{
IonCompleter
{
shell
,
history_completer
:
None
}
}
}
impl
<
'a
,
'b
>
Completer
for
IonCompleter
<
'a
,
'b
>
{
...
...
@@ -228,8 +230,8 @@ fn filename_completion<'a>(start: &'a str, path: &'a PathBuf) -> impl Iterator<I
let
globs
=
glob_with
(
&
string
,
MatchOptions
{
case_sensitive
:
true
,
require_literal_separator
:
true
,
case_sensitive
:
true
,
require_literal_separator
:
true
,
require_literal_leading_dot
:
false
,
},
)
...
...
@@ -261,7 +263,9 @@ fn filename_completion<'a>(start: &'a str, path: &'a PathBuf) -> impl Iterator<I
pub
struct
MultiCompleter
<
A
>
(
Vec
<
A
>
);
impl
<
A
>
MultiCompleter
<
A
>
{
pub
fn
new
(
completions
:
Vec
<
A
>
)
->
Self
{
MultiCompleter
(
completions
)
}
pub
fn
new
(
completions
:
Vec
<
A
>
)
->
Self
{
MultiCompleter
(
completions
)
}
}
impl
<
A
>
Completer
for
MultiCompleter
<
A
>
...
...
src/binary/designators.rs
View file @
9931344b
...
...
@@ -27,7 +27,9 @@ pub fn expand_designators<'a>(context: &Context, cmd: &'a str) -> Cow<'a, str> {
}
}
fn
command
(
text
:
&
str
)
->
&
str
{
ArgumentSplitter
::
new
(
text
)
.next
()
.unwrap_or
(
text
)
}
fn
command
(
text
:
&
str
)
->
&
str
{
ArgumentSplitter
::
new
(
text
)
.next
()
.unwrap_or
(
text
)
}
fn
args
(
text
:
&
str
)
->
&
str
{
let
bytes
=
text
.as_bytes
();
...
...
@@ -48,6 +50,10 @@ fn args(text: &str) -> &str {
.unwrap_or
(
text
)
}
fn
first_arg
(
text
:
&
str
)
->
&
str
{
ArgumentSplitter
::
new
(
text
)
.nth
(
1
)
.unwrap_or
(
text
)
}
fn
first_arg
(
text
:
&
str
)
->
&
str
{
ArgumentSplitter
::
new
(
text
)
.nth
(
1
)
.unwrap_or
(
text
)
}
fn
last_arg
(
text
:
&
str
)
->
&
str
{
ArgumentSplitter
::
new
(
text
)
.last
()
.unwrap_or
(
text
)
}
fn
last_arg
(
text
:
&
str
)
->
&
str
{
ArgumentSplitter
::
new
(
text
)
.last
()
.unwrap_or
(
text
)
}
src/binary/lexer.rs
View file @
9931344b
...
...
@@ -15,7 +15,7 @@ pub enum DesignatorToken<'a> {
#[derive(Debug)]
pub
struct
DesignatorLexer
<
'a
>
{
data
:
&
'a
[
u8
],
data
:
&
'a
[
u8
],
quotes
:
Quotes
,
design
:
bool
,
}
...
...
src/binary/mod.rs
View file @
9931344b
...
...
@@ -53,7 +53,7 @@ DESCRIPTION
pub
struct
InteractiveBinary
<
'a
>
{
context
:
Rc
<
RefCell
<
Context
>>
,
shell
:
RefCell
<
Shell
<
'a
>>
,
shell
:
RefCell
<
Shell
<
'a
>>
,
}
impl
<
'a
>
InteractiveBinary
<
'a
>
{
...
...
@@ -240,8 +240,8 @@ struct WordDivide<I>
where
I
:
Iterator
<
Item
=
(
usize
,
char
)
>
,
{
iter
:
I
,
count
:
usize
,
iter
:
I
,
count
:
usize
,
word_start
:
Option
<
usize
>
,
}
impl
<
I
>
WordDivide
<
I
>
...
...
src/lib/assignments/actions.rs
View file @
9931344b
...
...
@@ -36,11 +36,11 @@ pub enum AssignmentError<'a> {
/// string, and will contain the key/value pair to assign.
#[derive(Debug)]
pub
struct
AssignmentActions
<
'a
>
{
keys
:
KeyIterator
<
'a
>
,
keys
:
KeyIterator
<
'a
>
,
operator
:
Operator
,
values
:
ArgumentSplitter
<
'a
>
,
values
:
ArgumentSplitter
<
'a
>
,
prevkeys
:
Vec
<&
'a
str
>
,
prevval
:
&
'a
str
,
prevval
:
&
'a
str
,
}
impl
<
'a
>
AssignmentActions
<
'a
>
{
...
...
src/lib/builtins/exists.rs
View file @
9931344b
...
...
@@ -166,7 +166,9 @@ fn file_has_execute_permission(filepath: &str) -> bool {
}
/// Returns true if the string is not empty
fn
string_is_nonzero
(
string
:
&
str
)
->
bool
{
!
string
.is_empty
()
}
fn
string_is_nonzero
(
string
:
&
str
)
->
bool
{
!
string
.is_empty
()
}
/// Returns true if the variable is an array and the array is not empty
fn
array_var_is_not_empty
(
arrayvar
:
&
str
,
shell
:
&
Shell
<
'_
>
)
->
bool
{
...
...
src/lib/builtins/is.rs
View file @
9931344b
...
...
@@ -63,7 +63,9 @@ fn get_var_string(name: &str, shell: &mut Shell<'_>) -> types::Str {
#[test]
fn
test_is
()
{
fn
vec_string
(
args
:
&
[
&
str
])
->
Vec
<
types
::
Str
>
{
args
.iter
()
.map
(|
&
s
|
s
.into
())
.collect
()
}
fn
vec_string
(
args
:
&
[
&
str
])
->
Vec
<
types
::
Str
>
{
args
.iter
()
.map
(|
&
s
|
s
.into
())
.collect
()
}
let
mut
shell
=
Shell
::
default
();
shell
.variables_mut
()
.set
(
"x"
,
"value"
);
shell
.variables_mut
()
.set
(
"y"
,
"0"
);
...
...
src/lib/builtins/test.rs
View file @
9931344b
...
...
@@ -338,7 +338,9 @@ fn file_is_character_device(filepath: &str) -> bool {
}
/// Exits SUCCESS if the file exists
fn
file_exists
(
filepath
:
&
str
)
->
bool
{
Path
::
new
(
filepath
)
.exists
()
}
fn
file_exists
(
filepath
:
&
str
)
->
bool
{
Path
::
new
(
filepath
)
.exists
()
}
/// Exits SUCCESS if the file is a regular file
fn
file_is_regular
(
filepath
:
&
str
)
->
bool
{
...
...
@@ -356,10 +358,14 @@ fn file_is_symlink(filepath: &str) -> bool {
}
/// Exits SUCCESS if the string is not empty
fn
string_is_nonzero
(
string
:
&
str
)
->
bool
{
!
string
.is_empty
()
}
fn
string_is_nonzero
(
string
:
&
str
)
->
bool
{
!
string
.is_empty
()
}
/// Exits SUCCESS if the string is empty
fn
string_is_zero
(
string
:
&
str
)
->
bool
{
string
.is_empty
()
}
fn
string_is_zero
(
string
:
&
str
)
->
bool
{
string
.is_empty
()
}
#[test]
fn
test_strings
()
{
...
...
src/lib/expansion/braces.rs
View file @
9931344b
...
...
@@ -42,8 +42,8 @@ fn escape_string(output: &mut SmallVec<[u8; 64]>, input: &str) {
pub
struct
MultipleBraceExpand
<
'a
>
{
permutator
:
Permutator
<
'a
,
str
>
,
tokens
:
&
'a
[
BraceToken
],
buffer
:
Vec
<&
'a
str
>
,
tokens
:
&
'a
[
BraceToken
],
buffer
:
Vec
<&
'a
str
>
,
}
impl
<
'a
>
MultipleBraceExpand
<
'a
>
{
...
...
@@ -87,8 +87,8 @@ pub struct SingleBraceExpand<'a, 'b, I>
where
I
:
Iterator
<
Item
=
&
'a
str
>
,
{
elements
:
I
,
tokens
:
&
'b
[
BraceToken
],
elements
:
I
,
tokens
:
&
'b
[
BraceToken
],
loop_count
:
usize
,
}
...
...
src/lib/expansion/loops.rs
View file @
9931344b
...
...
@@ -3,12 +3,16 @@ use crate::{ranges, types};
/// The expression given to a for loop as the value to iterate upon.
pub
enum
ForValueExpression
{
/// A set of values
Multiple
(
Vec
<
types
::
Str
>
),
/// A single value
Normal
(
types
::
Str
),
/// A range of numbers
Range
(
Box
<
dyn
Iterator
<
Item
=
types
::
Str
>
+
'static
>
),
}
impl
ForValueExpression
{
/// Parse the arguments for the for loop
pub
fn
new
<
E
:
Expander
>
(
expression
:
&
[
types
::
Str
],
expanders
:
&
E
,
...
...
src/lib/expansion/methods/arrays.rs
View file @
9931344b
...
...
@@ -14,9 +14,9 @@ use unicode_segmentation::UnicodeSegmentation;
#[derive(Debug,
PartialEq,
Clone)]
pub
struct
ArrayMethod
<
'a
>
{
method
:
&
'a
str
,
variable
:
&
'a
str
,
pattern
:
Pattern
<
'a
>
,
method
:
&
'a
str
,
variable
:
&
'a
str
,
pattern
:
Pattern
<
'a
>
,
selection
:
Select
<
types
::
Str
>
,
}
...
...
src/lib/expansion/methods/mod.rs
View file @
9931344b
...
...
@@ -20,16 +20,22 @@ pub struct MethodArgs<'a, 'b, E: Expander> {
expand
:
&
'b
E
,
}
/// Error during method expansion
///
/// Ex: `$join($scalar)` (can't join a scala) or `$unknown(@variable)` (unknown method)
#[derive(Debug,
Clone,
Error)]
pub
enum
MethodError
{
/// Unknown array method
#[error(display
=
"'{}' is an unknown array method"
,
_0)]
InvalidArrayMethod
(
String
),
/// Unknown scalar method
#[error(display
=
"'{}' is an unknown string method"
,
_0)]
InvalidScalarMethod
(
String
),
/// A wrong argumeng was given to the method (extra, missing, or wrong type)
#[error(display
=
"{}: {}"
,
_0,
_1)]
WrongArgument
(
&
'static
str
,
&
'static
str
),
//
specific to some builtins
//
/ An invalid regex was provided. This is specific to the `matches` method
#[error(display
=
"regex_replace: error in regular expression '{}': {}"
,
_0,
_1)]
InvalidRegex
(
String
,
#[error(cause)]
regex
::
Error
),
}
...
...
src/lib/expansion/methods/strings.rs
View file @
9931344b
...
...
@@ -357,9 +357,9 @@ mod test {
fn
test_ends_with_succeeding
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"ends_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
BAR
\"
"
,
method
:
"ends_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
BAR
\"
"
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -370,9 +370,9 @@ mod test {
fn
test_ends_with_failing
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"ends_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
BA
\"
"
,
method
:
"ends_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
BA
\"
"
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -383,9 +383,9 @@ mod test {
fn
test_contains_succeeding
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"contains"
,
variable
:
"$FOO"
,
pattern
:
"
\"
OBA
\"
"
,
method
:
"contains"
,
variable
:
"$FOO"
,
pattern
:
"
\"
OBA
\"
"
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -396,9 +396,9 @@ mod test {
fn
test_contains_failing
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"contains"
,
variable
:
"$FOO"
,
pattern
:
"
\"
OBI
\"
"
,
method
:
"contains"
,
variable
:
"$FOO"
,
pattern
:
"
\"
OBI
\"
"
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -409,9 +409,9 @@ mod test {
fn
test_starts_with_succeeding
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"starts_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
FOO
\"
"
,
method
:
"starts_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
FOO
\"
"
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -422,9 +422,9 @@ mod test {
fn
test_starts_with_failing
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"starts_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
OO
\"
"
,
method
:
"starts_with"
,
variable
:
"$FOO"
,
pattern
:
"
\"
OO
\"
"
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -435,9 +435,9 @@ mod test {
fn
test_basename
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"basename"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
method
:
"basename"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -448,9 +448,9 @@ mod test {
fn
test_extension
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"extension"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
method
:
"extension"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -461,9 +461,9 @@ mod test {
fn
test_filename
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"filename"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
method
:
"filename"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -474,9 +474,9 @@ mod test {
fn
test_parent
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"parent"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
method
:
"parent"
,
variable
:
"
\"
/home/redox/file.txt
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -487,9 +487,9 @@ mod test {
fn
test_to_lowercase
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"to_lowercase"
,
variable
:
"
\"
Ford Prefect
\"
"
,
pattern
:
""
,
method
:
"to_lowercase"
,
variable
:
"
\"
Ford Prefect
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -500,9 +500,9 @@ mod test {
fn
test_to_uppercase
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"to_uppercase"
,
variable
:
"
\"
Ford Prefect
\"
"
,
pattern
:
""
,
method
:
"to_uppercase"
,
variable
:
"
\"
Ford Prefect
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -513,9 +513,9 @@ mod test {
fn
test_trim_with_string
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"trim"
,
variable
:
"
\"
Foo Bar
\"
"
,
pattern
:
""
,
method
:
"trim"
,
variable
:
"
\"
Foo Bar
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -525,12 +525,8 @@ mod test {
#[test]
fn
test_trim_with_variable
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"trim"
,
variable
:
"$BAZ"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
let
method
=
StringMethod
{
method
:
"trim"
,
variable
:
"$BAZ"
,
pattern
:
""
,
selection
:
Select
::
All
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
assert_eq!
(
&*
output
,
"BARBAZ"
);
}
...
...
@@ -539,9 +535,9 @@ mod test {
fn
test_trim_right_with_string
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"trim_right"
,
variable
:
"
\"
Foo Bar
\"
"
,
pattern
:
""
,
method
:
"trim_right"
,
variable
:
"
\"
Foo Bar
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -552,9 +548,9 @@ mod test {
fn
test_trim_right_with_variable
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"trim_right"
,
variable
:
"$BAZ"
,
pattern
:
""
,
method
:
"trim_right"
,
variable
:
"$BAZ"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -565,9 +561,9 @@ mod test {
fn
test_trim_left_with_string
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"trim_left"
,
variable
:
"
\"
Foo Bar
\"
"
,
pattern
:
""
,
method
:
"trim_left"
,
variable
:
"
\"
Foo Bar
\"
"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -578,9 +574,9 @@ mod test {
fn
test_trim_left_with_variable
()
{
let
mut
output
=
types
::
Str
::
new
();
let
method
=
StringMethod
{
method
:
"trim_left"
,
variable
:
"$BAZ"
,
pattern
:
""
,
method
:
"trim_left"
,
variable
:
"$BAZ"
,
pattern
:
""
,
selection
:
Select
::
All
,
};
method
.handle
(
&
mut
output
,
&
DummyExpander
)
.unwrap
();
...
...
@@ -591,9 +587,9 @@ mod test {
fn
test_repeat_succeeding
()
{
let
mut
output
=
types
::
Str
::
new
();