[][src]Struct rslint_core::groups::errors::ForDirection

pub struct ForDirection {}

Disallow for loops which update their counter in the wrong direction.

A for loop with a counter may update its value in the wrong direction. that is to say, if i made a counter with a value of 0, if the for statement checked if counter < 10 and the update went counter--, that loop would be infinite. This is because counter will never be smaller than 10 because counter-- always yields a value smaller than 10. A for loop which does this is almost always a bug because it is either unreachable or infinite.

Incorrect Code Examples

for (var i = 0; i < 10; i--) {
    /* infinite loop */
}
for (var i = 10; i >= 20; i++) {
    /* unreachable */
}

Correct Code Examples

for (var i = 0; i < 10; i++) {

}

Implementations

impl ForDirection[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for ForDirection[src]

impl CstRule for ForDirection[src]

impl Debug for ForDirection[src]

impl Default for ForDirection[src]

impl<'de> Deserialize<'de> for ForDirection[src]

impl Rule for ForDirection[src]

impl Serialize for ForDirection[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> Erasable for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.