Skip to content

Commit 21bdfda

Browse files
elliotttpchickey
andauthored
Add fields.has (#91)
* Revert changes to `fields.get`, and add `fields.has` * Clarify the return value of `fields.get` --------- Co-authored-by: Pat Hickey <[email protected]>
1 parent 7b74a93 commit 21bdfda

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

proxy.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,10 @@ syntactically invalid, or if a header was forbidden.</p>
745745
<li><a name="static_fields.from_list.0"></a> result&lt;own&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;, <a href="#header_error"><a href="#header_error"><code>header-error</code></a></a>&gt;</li>
746746
</ul>
747747
<h4><a name="method_fields.get"><code>[method]fields.get: func</code></a></h4>
748-
<p>Get all of the values corresponding to a key.</p>
748+
<p>Get all of the values corresponding to a key. If the key is not present
749+
in this <a href="#fields"><code>fields</code></a>, an empty list is returned. However, if the key is
750+
present but empty, this is represented by a list with one or more
751+
empty field-values present.</p>
749752
<h5>Params</h5>
750753
<ul>
751754
<li><a name="method_fields.get.self"><code>self</code></a>: borrow&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
@@ -755,6 +758,18 @@ syntactically invalid, or if a header was forbidden.</p>
755758
<ul>
756759
<li><a name="method_fields.get.0"></a> list&lt;<a href="#field_value"><a href="#field_value"><code>field-value</code></a></a>&gt;</li>
757760
</ul>
761+
<h4><a name="method_fields.has"><code>[method]fields.has: func</code></a></h4>
762+
<p>Returns <code>true</code> when the key is present in this <a href="#fields"><code>fields</code></a>. If the key is
763+
syntactically invalid, <code>false</code> is returned.</p>
764+
<h5>Params</h5>
765+
<ul>
766+
<li><a name="method_fields.has.self"><code>self</code></a>: borrow&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
767+
<li><a name="method_fields.has.name"><code>name</code></a>: <a href="#field_key"><a href="#field_key"><code>field-key</code></a></a></li>
768+
</ul>
769+
<h5>Return values</h5>
770+
<ul>
771+
<li><a name="method_fields.has.0"></a> <code>bool</code></li>
772+
</ul>
758773
<h4><a name="method_fields.set"><code>[method]fields.set: func</code></a></h4>
759774
<p>Set all of the values for a key. Clears any existing values for that
760775
key, if they have been set.</p>

wit/types.wit

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,16 @@ interface types {
169169
entries: list<tuple<field-key,field-value>>
170170
) -> result<fields, header-error>;
171171

172-
/// Get all of the values corresponding to a key.
172+
/// Get all of the values corresponding to a key. If the key is not present
173+
/// in this `fields`, an empty list is returned. However, if the key is
174+
/// present but empty, this is represented by a list with one or more
175+
/// empty field-values present.
173176
get: func(name: field-key) -> list<field-value>;
174177

178+
/// Returns `true` when the key is present in this `fields`. If the key is
179+
/// syntactically invalid, `false` is returned.
180+
has: func(name: field-key) -> bool;
181+
175182
/// Set all of the values for a key. Clears any existing values for that
176183
/// key, if they have been set.
177184
///

0 commit comments

Comments
 (0)