---
title: Exclusive char or byte range is missing its last character
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Exclusive char or byte range is missing its last character
---

# Exclusive char or byte range is missing its last character

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `rust-code-quality/almost-complete-range`

**Language:** Rust

**Severity:** Error

**Category:** Error Prone

**CWE**: [193](https://cwe.mitre.org/data/definitions/193.html)

## Description{% #description %}

A range like `'a'..'z'` excludes the last character and is almost certainly a typo for the inclusive range `'a'..='z'`. The same applies to `'A'..'Z'` and `'0'..'9'`, as well as their byte literal equivalents (`b'a'..b'z'`, etc.)

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```rust
fn is_lowercase(c: char) -> bool {
  ('a'..'z').contains(&c)
}

fn is_digit_byte(b: u8) -> bool {
  (b'0'..b'9').contains(&b)
}
```

## Compliant Code Examples{% #compliant-code-examples %}

```rust
fn is_lowercase(c: char) -> bool {
  ('a'..='z').contains(&c)  
}

fn is_digit_byte(b: u8) -> bool {
  (b'0'..='9').contains(&b) 
}

fn beginning_to_f(c: char) -> bool {
  ('a'..'f').contains(&c)
}  
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 