|
1 | 1 | use std::borrow::Cow; |
2 | 2 |
|
3 | | -use crate::svd::{ |
4 | | - Access, Cluster, Device, Field, Register, RegisterCluster, RegisterInfo, RegisterProperties, |
5 | | -}; |
| 3 | +use crate::svd::{Access, Cluster, Device, Field, Register, RegisterInfo, RegisterProperties}; |
6 | 4 | use inflections::Inflect; |
7 | 5 | use proc_macro2::{Ident, Literal, Span, TokenStream}; |
8 | 6 | use quote::{quote, ToTokens}; |
@@ -333,7 +331,7 @@ pub fn register_path_to_ty( |
333 | 331 | } |
334 | 332 | ident.push_str("::"); |
335 | 333 | ident.push_str(&rpath.name.to_sanitized_snake_case()); |
336 | | - Ok(syn::Type::Path(parse_str::<syn::TypePath>(&ident)?)) |
| 334 | + parse_str::<syn::TypePath>(&ident).map(syn::Type::Path) |
337 | 335 | } |
338 | 336 |
|
339 | 337 | pub trait U32Ext { |
@@ -393,42 +391,6 @@ impl U32Ext for u32 { |
393 | 391 | } |
394 | 392 | } |
395 | 393 |
|
396 | | -/// Return the name of either register or cluster. |
397 | | -pub fn erc_name(erc: &RegisterCluster) -> &String { |
398 | | - match erc { |
399 | | - RegisterCluster::Register(r) => &r.name, |
400 | | - RegisterCluster::Cluster(c) => &c.name, |
401 | | - } |
402 | | -} |
403 | | - |
404 | | -/// Return the name of either register or cluster from which this register or cluster is derived. |
405 | | -pub fn erc_derived_from(erc: &RegisterCluster) -> &Option<String> { |
406 | | - match erc { |
407 | | - RegisterCluster::Register(r) => &r.derived_from, |
408 | | - RegisterCluster::Cluster(c) => &c.derived_from, |
409 | | - } |
410 | | -} |
411 | | - |
412 | | -/// Return only the clusters from the slice of either register or clusters. |
413 | | -pub fn only_clusters(ercs: &[RegisterCluster]) -> Vec<&Cluster> { |
414 | | - ercs.iter() |
415 | | - .filter_map(|x| match x { |
416 | | - RegisterCluster::Cluster(x) => Some(x), |
417 | | - _ => None, |
418 | | - }) |
419 | | - .collect() |
420 | | -} |
421 | | - |
422 | | -/// Return only the registers the given slice of either register or clusters. |
423 | | -pub fn only_registers(ercs: &[RegisterCluster]) -> Vec<&Register> { |
424 | | - ercs.iter() |
425 | | - .filter_map(|x| match x { |
426 | | - RegisterCluster::Register(x) => Some(x), |
427 | | - _ => None, |
428 | | - }) |
429 | | - .collect() |
430 | | -} |
431 | | - |
432 | 394 | pub fn build_rs() -> TokenStream { |
433 | 395 | quote! { |
434 | 396 | use std::env; |
|
0 commit comments