> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Primitive type CtString

Module: `std`

A a compile-time, dynamically-sized string type.

Compared to [`str`](/aztec-nr-api/v6.0.0/std/primitive.str.md)`<N>` and [`fmtstr`](/aztec-nr-api/v6.0.0/std/primitive.fmtstr.md)`<N, T>`, `CtString` is useful because its size does not need to be specified in its type. This can be used for formatting items at compile-time or general string handling in `comptime` code.

Since [`fmtstr`](/aztec-nr-api/v6.0.0/std/primitive.fmtstr.md)s can be converted into `CtString`s, you can make use of their formatting abilities in CtStrings by formatting in [`fmtstr`](/aztec-nr-api/v6.0.0/std/primitive.fmtstr.md)s then converting the result to a CtString afterward.

## Implementations

```rust
impl CtString
```

```rust
pub comptime fn new() -> Self
```

```rust
pub comptime fn append_str<let N: u32>(self, s: str<N>) -> Self
```

```rust
pub comptime fn append_fmtstr<let N: u32, T>(self, s: fmtstr<N, T>) -> Self
```

```rust
pub comptime fn as_quoted_str(self) -> Quoted
```

CtString cannot directly return a str since the size would not be known. To get around this, we return a quoted str and the underlying str can be accessed using macro insertion `foo.as_quoted_str!()`.

## Trait implementations

```rust
impl Append for CtString
```

```rust
pub comptime fn empty() -> Self
```

```rust
pub comptime fn append(self, other: Self) -> Self
```

```rust
impl Eq for CtString
```

```rust
pub comptime fn eq(self, other: Self) -> bool
```

```rust
impl Hash for CtString
```

```rust
pub comptime fn hash<H>(self, state: &mut H)
where
    H: Hasher
```
