Skip to content

Commit 605eef9

Browse files
author
InAnYan
committed
Remove redunant from_iter
1 parent 6615ccf commit 605eef9

File tree

2 files changed

+0
-110
lines changed

2 files changed

+0
-110
lines changed

module/move/assistant/src/agents/path.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ mod private
2424
/// If you want to match against this expression, use `PATH_ITEM_REGEX`.
2525
pub const PATH_ITEM_REGEX_STR : &str = r"[a-zA-Z0-9_ -]+";
2626

27-
/// Regular expression for `Path` items. You can match whole `&str` with this type.
28-
///
29-
/// To match whole `Path` in strings, use `PATH_REGEX`.
30-
pub static PATH_ITEM_REGEX : LazyLock< Regex > = LazyLock::new( ||
31-
{
32-
let regex = format!
33-
(
34-
r"^{}$",
35-
PATH_ITEM_REGEX_STR
36-
);
37-
38-
Regex::new( &regex ).unwrap()
39-
});
40-
4127
/// Regular expression for `Path`. You can match whole `&str` with this type.
4228
pub static PATH_REGEX : LazyLock< Regex > = LazyLock::new( ||
4329
{
@@ -148,54 +134,6 @@ mod private
148134
self.0
149135
}
150136

151-
/// Creates a relative `Path` from an iterator over items that implement `AsRef<str>`.
152-
/// To create an absolute `Path`, use `from_iter_abs` method.
153-
///
154-
/// Returns `Err(io::Error)` if the items are not valid `Path` items.
155-
pub fn from_iter_rel< 'a >( iter : impl Iterator< Item = &'a str > ) -> Result< Self, io::Error >
156-
{
157-
iter.map( | path_element_str |
158-
{
159-
if PATH_ITEM_REGEX.is_match( path_element_str )
160-
{
161-
Ok ( path_element_str )
162-
}
163-
else
164-
{
165-
Err ( io::Error::from( io::ErrorKind::InvalidData ) )
166-
}
167-
})
168-
.process_results( | mut item_iter |
169-
{
170-
Self( item_iter.join( PATH_SEPARATOR ) )
171-
})
172-
}
173-
174-
/// Creates an absolute `Path` from an iterator over strings.
175-
/// To create a relative `Path`, use `from_iter_rel` method.
176-
///
177-
/// Returns `Err(io::Error)` if the items are not valid `Path` items.
178-
pub fn from_iter_abs< 'a >( iter : impl Iterator< Item = &'a str > ) -> Result< Self, io::Error >
179-
{
180-
iter.map( | path_element_str |
181-
{
182-
if PATH_ITEM_REGEX.is_match( path_element_str )
183-
{
184-
Ok ( path_element_str )
185-
}
186-
else
187-
{
188-
Err ( io::Error::from( io::ErrorKind::InvalidData ) )
189-
}
190-
})
191-
.process_results( | mut item_iter |
192-
{
193-
let mut res = item_iter.join( PATH_SEPARATOR );
194-
res.insert_str( 0, PATH_SEPARATOR );
195-
Self( res )
196-
})
197-
}
198-
199137
/// Iterate over components of a `Path`. If the `Path` is absolute, then the first
200138
/// element will be `::`.
201139
pub fn components( &self ) -> impl Iterator< Item = &str >

module/move/assistant/tests/inc/agents_tests/path_test.rs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -251,54 +251,6 @@ fn path_inner()
251251
assert_eq!( inner, path_str );
252252
}
253253

254-
#[ test ]
255-
fn path_from_iter_right()
256-
{
257-
let expected = "agents::completion";
258-
let elements = vec![ "agents", "completion" ];
259-
260-
let path = Path::from_iter_rel( elements.into_iter() );
261-
262-
assert!( path.is_ok() );
263-
let path = path.unwrap();
264-
assert!( path.is_relative() );
265-
assert_eq!( path.inner(), expected );
266-
}
267-
268-
#[ test ]
269-
fn path_from_iter_wrong_item()
270-
{
271-
let elements = vec![ "agents:", "completion" ];
272-
273-
let path = Path::from_iter_rel( elements.into_iter() );
274-
275-
assert!( path.is_err() );
276-
}
277-
278-
#[ test ]
279-
fn path_from_iter_wrong_separator()
280-
{
281-
let elements = vec![ "agents", "::", "completion" ];
282-
283-
let path = Path::from_iter_rel( elements.into_iter() );
284-
285-
assert!( path.is_err() );
286-
}
287-
288-
#[ test ]
289-
fn path_from_iter_abs()
290-
{
291-
let expected = "::agents::completion";
292-
let elements = vec![ "agents", "completion" ];
293-
294-
let path = Path::from_iter_abs( elements.into_iter() );
295-
296-
assert!( path.is_ok() );
297-
let path = path.unwrap();
298-
assert!( path.is_absolute() );
299-
assert_eq!( path.inner(), expected );
300-
}
301-
302254
#[ test ]
303255
fn path_components()
304256
{

0 commit comments

Comments
 (0)