Function in bytes coil-stdlib

to_hex

fn to_hex(Vec<byte> buf) -> string
Import
use bytes::{to_hex};
Source: src/bytes.hy

Encodes buf as lowercase hexadecimal, two digits per byte.

Parameters#

NameType
bufVec<byte>

Returns#

string

Contracts#

Checked according to --contracts (see Contracts).

ensures result.len() == 2 * buf.len()

Examples#

use bytes::{to_hex};
use tests::assert;
assert!(to_hex(Vec::from([0 as byte, 171 as byte, 255 as byte])) == "00abff");

See also#

  • region_eq: True when a[ao..ao+n) equals b[bo..bo+n) (caller guarantees bounds).
  • from_hex: Decodes hexadecimal text (either case) into bytes.
  • slice: Returns a copy of src[start..end] (end exclusive), with both offsets clamped to the buffer.
  • concat: Returns a new buffer holding a followed by b.
  • eq: Returns true when a and b have the same length and the same bytes.
  • find_from: Returns the offset of the first needle in hay at or after start, or -1.
  • find: Returns the offset of the first needle in hay, or -1.
  • rfind: Returns the offset of the last needle in hay, or -1.
↑ ↓ navigate ↵ open