query
On this page

stringLength

lib.strings.stringLength

Primop
Docs pulled from | This Revision | 31 minutes ago


Nix manual

Takes 1 arguments

e

Return the number of bytes of the string e. If e is not a string, evaluation is aborted.

Noogle detected

Aliases

Detected Type
stringLength :: String -> Int

Implementation

This function is implemented in c++ and is part of the native nix runtime.

src/libexpr/primops.cc:4761

static void prim_stringLength(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
    NixStringContext context;
    auto s =
        state.coerceToString(pos, *args[0], context, "while evaluating the argument passed to builtins.stringLength");
    v.mkInt(NixInt::Inner(s->size()));
}

Implementation

The following is the current implementation of this function.

stringLength