Skip to content

Commit

Permalink
Fix new Clippy issues
Browse files Browse the repository at this point in the history
Newer clippy does not seem to like get(0) but prefer first()
  • Loading branch information
erikbosch authored and SebastianSchildt committed Jan 25, 2024
1 parent 92885c6 commit 509406d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl proto::val_server::Val for broker::DataBroker {

// Not sure how to handle the "global error".
// Fall back to just use the first path specific error if any
let error = match errors.get(0) {
let error = match errors.first() {
Some(first) => first.error.clone(),
None => None,
};
Expand Down
4 changes: 2 additions & 2 deletions kuksa_databroker/databroker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn add_kuksa_attribute(
)];
if let Err(errors) = database.update_entries(ids).await {
// There's only one error (since we're only trying to set one)
if let Some(error) = errors.get(0) {
if let Some(error) = errors.first() {
info!("Failed to set value for {}: {:?}", attribute, error.1);
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ async fn read_metadata_file<'a, 'b>(
)];
if let Err(errors) = database.update_entries(ids).await {
// There's only one error (since we're only trying to set one)
if let Some(error) = errors.get(0) {
if let Some(error) = errors.first() {
info!("Failed to set default value for {}: {:?}", path, error.1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions kuksa_databroker/databroker/src/query/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct CompiledQuery {
/// or as part of a condition.
///
/// These needs to be provided in the `input` when
/// executing the query.
/// executing the query.
pub input_spec: HashSet<String>, // Needed datapoints (values) for execution
}

Expand Down Expand Up @@ -412,7 +412,7 @@ pub fn compile(

match sqlparser::parser::Parser::parse_sql(&dialect, sql) {
Ok(ast) => {
let select_statement = match &ast.get(0) {
let select_statement = match &ast.first() {
Some(sqlparser::ast::Statement::Query(q)) => match &q.body {
sqlparser::ast::SetExpr::Select(query) => Some(query.clone()),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion kuksa_databroker/databroker/src/viss/v2/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl Viss for Server {
ts: SystemTime::now().into(),
}),
Err(errors) => {
let error = if let Some((_, error)) = errors.get(0) {
let error = if let Some((_, error)) = errors.first() {
match error {
UpdateError::NotFound => Error::NotFoundInvalidPath,
UpdateError::WrongType => Error::BadRequest {
Expand Down

0 comments on commit 509406d

Please sign in to comment.