summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/overview_code.c5
-rw-r--r--doc/string_views.rst13
2 files changed, 15 insertions, 3 deletions
diff --git a/doc/overview_code.c b/doc/overview_code.c
index 1370292..2f6a099 100644
--- a/doc/overview_code.c
+++ b/doc/overview_code.c
@@ -1,4 +1,4 @@
-// Copyright 2021-2022 David Robillard <d@drobilla.net>
+// Copyright 2021-2023 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
/*
@@ -26,8 +26,9 @@ string_views(void)
// end make-empty-string
// begin make-static-string
- ZixStringView hello = zix_string("hello");
+ static const ZixStringView hello = ZIX_STATIC_STRING("hello");
// end make-static-string
+ (void)hello;
// begin measure-string
ZixStringView view = zix_string(string_pointer);
diff --git a/doc/string_views.rst b/doc/string_views.rst
index b6e3fd9..6c049f3 100644
--- a/doc/string_views.rst
+++ b/doc/string_views.rst
@@ -1,5 +1,5 @@
..
- Copyright 2020-2022 David Robillard <d@drobilla.net>
+ Copyright 2020-2023 David Robillard <d@drobilla.net>
SPDX-License-Identifier: ISC
String Views
@@ -15,6 +15,17 @@ This forces code to be explicit about string measurement,
which discourages common patterns of repeated measurement of the same string.
For convenience, several macros and functions are provided for constructing string views:
+:macro:`ZIX_STATIC_STRING`
+
+ Initializes a string view from a string literal. Note that this may only be
+ used with inlined string literals, passing a pointer to an arbitrary string
+ is undefined behaviour, for example:
+
+ .. literalinclude:: overview_code.c
+ :start-after: begin make-static-string
+ :end-before: end make-static-string
+ :dedent: 2
+
:func:`zix_empty_string`
Constructs a view of an empty string, for example: