Struct advent_of_code_2021::day_16::Packet[−][src]

struct Packet {
    version: usize,
    packet_type: PacketType,
    sub_packets: Vec<Packet>,
    value: usize,
}
Expand description

Represents a packet in BITS

Fields

version: usize

The version (0-7)

packet_type: PacketType

Indicates what this packet represents

sub_packets: Vec<Packet>

List of sub-packets. For PacketType::Literal this will be empty

value: usize

The literal value, for PacketTypes other than PacketType::Literal

Implementations

Solution to part one. Returns the sum of this packet’s version and the version sum of all sub-packets

Solution to part two. Recursively compute the value of applying the current operation to the contained sub-packets’ computed values, or return the value in the case of a literal node.

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.