MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / as_slice

Method as_slice

atomic-canonical/src/node.rs:183–190  ·  view source on GitHub ↗

The criteria as a slice, whatever the shape on disk. Callers use this instead of matching, so the legacy variant stays invisible to them.

(&self)

Source from the content-addressed store, hash-verified

181 /// The criteria as a slice, whatever the shape on disk. Callers use this
182 /// instead of matching, so the legacy variant stays invisible to them.
183 pub fn as_slice(&self) -> &[String] {
184 match self {
185 // `from_ref` lets a scalar masquerade as a one-element slice without
186 // allocating — and, crucially, without rewriting the stored form.
187 Self::One(one) => std::slice::from_ref(one),
188 Self::Many(many) => many,
189 }
190 }
191
192 /// True when no criteria are referenced. Drives `skip_serializing_if`, so an
193 /// empty list is omitted exactly as it was under the plain `Vec`.

Calls

no outgoing calls