~sircmpwn/hare-users

2 2

Tuples

Details
Message ID
<415714bc-c4d4-9c01-a901-12275168770c@gmail.com>
DKIM signature
pass
Download raw message
I'd like to use the bytes::cut() function. The doc reads:

// Returns the input slice "cut" along the first instance of a delimiter,
// returning everything up to the delimiter, and everything after the 
delimiter,
// in a tuple. The contents are borrowed from the input slice.
//
// The caller must ensure that 'delimiter' is not an empty slice.
fn cut(in: []u8, delim: ([]u8 | u8)) ([]u8, []u8);

I noticed that I can't write something like:

     let (hd, tail) = bytes::cut(contents, delim);

so I have to write something like

     let tup = bytes::cut(contents, delim);


My question is: how do I access the parts of the tuple?
Details
Message ID
<COOW8B6SZK84.2DKLLRXQISX2S@taiga>
In-Reply-To
<415714bc-c4d4-9c01-a901-12275168770c@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Tue Nov 29, 2022 at 4:42 PM CET, Person wrote:
> I noticed that I can't write something like:
>
>      let (hd, tail) = bytes::cut(contents, delim);

This should work, assuming your toolchain is up to date.

> so I have to write something like
>
>      let tup = bytes::cut(contents, delim);
>
> My question is: how do I access the parts of the tuple?

tup.0, tup.1, etc
Details
Message ID
<cfd6c4ec-6c84-e65d-75c6-712300438616@gmail.com>
In-Reply-To
<COOW8B6SZK84.2DKLLRXQISX2S@taiga> (view parent)
DKIM signature
pass
Download raw message
Thanks Drew.

OK, so I pulled the latest for harec and hare and recompiled. That did 
the trick.
Reply to thread Export thread (mbox)