style: prefer turbofish syntax where possible

This commit is contained in:
Amaan Qureshi 2024-02-19 14:50:29 -05:00
parent fd91404ab0
commit b40839cd72
12 changed files with 28 additions and 29 deletions

View file

@ -158,10 +158,10 @@ fn test_parsing_with_custom_utf16_input() {
let mut parser = Parser::new();
parser.set_language(&get_language("rust")).unwrap();
let lines: Vec<Vec<u16>> = ["pub fn foo() {", " 1", "}"]
let lines = ["pub fn foo() {", " 1", "}"]
.iter()
.map(|s| s.encode_utf16().collect())
.collect();
.map(|s| s.encode_utf16().collect::<Vec<_>>())
.collect::<Vec<_>>();
let tree = parser
.parse_utf16_with(
@ -1014,11 +1014,11 @@ fn test_parsing_error_in_invalid_included_ranges() {
#[test]
fn test_parsing_utf16_code_with_errors_at_the_end_of_an_included_range() {
let source_code = "<script>a.</script>";
let utf16_source_code: Vec<u16> = source_code
let utf16_source_code = source_code
.as_bytes()
.iter()
.map(|c| u16::from(*c))
.collect();
.collect::<Vec<_>>();
let start_byte = 2 * source_code.find("a.").unwrap();
let end_byte = 2 * source_code.find("</script>").unwrap();

View file

@ -397,14 +397,14 @@ fn test_tags_via_c_api() {
})
.unwrap();
let syntax_types: Vec<&str> = unsafe {
let syntax_types = unsafe {
let mut len: u32 = 0;
let ptr =
c::ts_tagger_syntax_kinds_for_scope_name(tagger, c_scope_name.as_ptr(), &mut len);
slice::from_raw_parts(ptr, len as usize)
.iter()
.map(|i| CStr::from_ptr(*i).to_str().unwrap())
.collect()
.collect::<Vec<_>>()
};
assert_eq!(

View file

@ -72,7 +72,7 @@ fn test_text_provider_for_string() {
#[test]
fn test_text_provider_for_box_of_str_slice() {
let text: Box<str> = "// comment".to_owned().into_boxed_str();
let text = "// comment".to_owned().into_boxed_str();
check_parsing(text.as_bytes(), text.as_bytes());
check_parsing(<_ as AsRef<str>>::as_ref(&text), text.as_bytes());
@ -82,7 +82,7 @@ fn test_text_provider_for_box_of_str_slice() {
#[test]
fn test_text_provider_for_box_of_bytes_slice() {
let text: Box<[u8]> = "// comment".to_owned().into_boxed_str().into_boxed_bytes();
let text = "// comment".to_owned().into_boxed_str().into_boxed_bytes();
check_parsing(text.as_ref(), text.as_ref());
check_parsing(text.as_ref(), &*text);
@ -91,15 +91,14 @@ fn test_text_provider_for_box_of_bytes_slice() {
#[test]
fn test_text_provider_for_vec_of_bytes() {
let text: Vec<u8> = "// comment".to_owned().into_bytes();
let text = "// comment".to_owned().into_bytes();
check_parsing(&*text, &*text);
}
#[test]
fn test_text_provider_for_arc_of_bytes_slice() {
let text: Vec<u8> = "// comment".to_owned().into_bytes();
let text: Arc<[u8]> = Arc::from(text);
let text: Arc<[u8]> = Arc::from("// comment".to_owned().into_bytes());
check_parsing(&*text, &*text);
check_parsing(text.as_ref(), text.as_ref());
@ -149,7 +148,7 @@ fn test_text_provider_callback_with_owned_bytes_vec_slice() {
.unwrap_or_default()
},
|_node: Node<'_>| {
let slice: Vec<u8> = text.to_owned().into_bytes();
let slice = text.to_owned().into_bytes();
iter::once(slice)
},
);