[−][src]Struct rslint_core::groups::errors::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]
Trait Implementations
impl Clone for ForDirection
[src]
fn clone(&self) -> ForDirection
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl CstRule for ForDirection
[src]
fn check_node(&self, node: &SyntaxNode, ctx: &mut RuleCtx) -> Option<()>
[src]
fn check_token(&self, token: &SyntaxToken, ctx: &mut RuleCtx) -> Option<()>
[src]
fn check_root(&self, root: &SyntaxNode, ctx: &mut RuleCtx) -> Option<()>
[src]
impl Debug for ForDirection
[src]
impl Default for ForDirection
[src]
fn default() -> ForDirection
[src]
impl<'de> Deserialize<'de> for ForDirection
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Rule for ForDirection
[src]
impl Serialize for ForDirection
[src]
Auto Trait Implementations
impl RefUnwindSafe for ForDirection
impl Send for ForDirection
impl Sync for ForDirection
impl Unpin for ForDirection
impl UnwindSafe for ForDirection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> Erasable for T
unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>
const ACK_1_1_0: bool
fn erase(this: NonNull<Self>) -> NonNull<Erased>
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,