Skip to content

Commit 7590bf8

Browse files
committed
Clippy
1 parent 3b4fed5 commit 7590bf8

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/atom.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ impl Atom {
187187

188188
impl Atom {
189189
/// Get the car of the atom if it is a pair, else return the atom itself.
190+
#[must_use]
190191
pub fn car(&self) -> Rc<Atom> {
191192
match self {
192193
Atom::Pair(car, _) => car.clone(),
@@ -195,6 +196,7 @@ impl Atom {
195196
}
196197

197198
/// Get the cdr of the atom if it is a pair, else return the atom itself.
199+
#[must_use]
198200
pub fn cdr(&self) -> Rc<Atom> {
199201
match self {
200202
Atom::Pair(_, cdr) => cdr.clone(),
@@ -220,6 +222,7 @@ impl Atom {
220222
}
221223

222224
/// Returns true if the atom is nil. False otherwise
225+
#[must_use]
223226
pub fn is_nil(&self) -> bool {
224227
match self {
225228
Atom::Symbol(sym) => sym.as_str() == "nil",
@@ -230,6 +233,7 @@ impl Atom {
230233
/// Return true if the atom is a proper list.
231234
///
232235
/// A proper list is a cons list where the last element is nil.
236+
#[must_use]
233237
pub fn is_proper_list(expr: Rc<Self>) -> bool {
234238
let mut expr = expr;
235239
while !expr.is_nil() {
@@ -243,6 +247,7 @@ impl Atom {
243247
}
244248

245249
/// Return true if the atom is a pair.
250+
#[must_use]
246251
pub fn is_list(expr: &Rc<Self>) -> bool {
247252
matches!(expr.as_ref(), Atom::Pair(_, _))
248253
}
@@ -366,6 +371,7 @@ impl Atom {
366371
}
367372

368373
/// Return false if the atom is nil
374+
#[must_use]
369375
pub fn as_bool(&self) -> bool {
370376
!self.is_nil()
371377
}
@@ -396,6 +402,7 @@ impl Atom {
396402

397403
/// WARNING: This is probably broken, and should only be used when it doesn't matter much.
398404
/// Currently it is used in the pretty printer, where it is used to count the lenght of a list.
405+
#[must_use]
399406
pub fn into_vec(atom: Rc<Self>) -> Vec<Rc<Self>> {
400407
match atom.as_ref() {
401408
Atom::Pair(car, cdr) => {
@@ -410,6 +417,7 @@ impl Atom {
410417
}
411418

412419
/// Get length of list including sublists, or length of string if atom is a string.
420+
#[must_use]
413421
pub fn get_list_lenght_including_inner(&self) -> usize {
414422
match self {
415423
Atom::Pair(car, cdr) => {
@@ -422,6 +430,7 @@ impl Atom {
422430
}
423431

424432
/// Get length of list including sublists.
433+
#[must_use]
425434
pub fn get_list_lenght_including_inner_without_symbol(&self) -> usize {
426435
match self {
427436
Atom::Pair(car, cdr) => {

src/atom/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn list_evaluation(
5151
))?;
5252
let args = cdr;
5353

54-
match op.as_ref() {
54+
match &op.as_ref() {
5555
Atom::Symbol(symbol) => try_evaluate_special_form(symbol, args, env).context(format!(
5656
"While trying to evaluate special form {:?}",
5757
symbol

src/env.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ impl Env {
370370
}
371371

372372
/// Get a value from the environment, trying parent environments if the key is not found.
373+
///
374+
/// # Errors
375+
///
376+
/// If the key is not found in any environment, return an error.
373377
pub fn get(&self, name: &str) -> Result<Rc<Atom>> {
374378
match self.bindings.get(&Rc::new(name.to_string())) {
375379
Some(atom) => Ok(atom.clone()),

0 commit comments

Comments
 (0)