Skip to content

[Question] how do I create a BStr from &[u8] ? #107

Answered by lopopolo
jtmoon79 asked this question in Q&A
Discussion options

You must be logged in to vote

I think this is how you're meant to do it:

use bstr::ByteSlice;

let a = [0_u8; 3];
let b = a.as_bstr();

Most of the APIs in this crate come from either ByteSlice or ByteVec. These are extension traits, which means when they are imported, they make methods available on vecs and slices that bstr implements these traits on.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #102 on July 05, 2022 16:15.