Struct qt_core::QBitArray

source ·
#[repr(C)]
pub struct QBitArray { /* private fields */ }
Expand description

The QBitArray class provides an array of bits.

C++ class: QBitArray.

C++ documentation:

The QBitArray class provides an array of bits.

A QBitArray is an array that gives access to individual bits and provides operators (AND, OR, XOR, and NOT) that work on entire arrays of bits. It uses implicit sharing (copy-on-write) to reduce memory usage and to avoid the needless copying of data.

The following code constructs a QBitArray containing 200 bits initialized to false (0):

QBitArray ba(200);

To initialize the bits to true, either pass true as second argument to the constructor, or call fill() later on.

QBitArray uses 0-based indexes, just like C++ arrays. To access the bit at a particular index position, you can use operator[](). On non-const bit arrays, operator[]() returns a reference to a bit that can be used on the left side of an assignment. For example:

QBitArray ba; ba.resize(3); ba[0] = true; ba[1] = false; ba[2] = true;

For technical reasons, it is more efficient to use testBit() and setBit() to access bits in the array than operator[](). For example:

QBitArray ba(3); ba.setBit(0, true); ba.setBit(1, false); ba.setBit(2, true);

QBitArray supports & (AND), | (OR), ^ (XOR), ~ (NOT), as well as &=, |=, and ^=. These operators work in the same way as the built-in C++ bitwise operators of the same name. For example:

QBitArray x(5); x.setBit(3, true); // x: [ 0, 0, 0, 1, 0 ]

QBitArray y(5); y.setBit(4, true); // y: [ 0, 0, 0, 0, 1 ]

x |= y; // x: [ 0, 0, 0, 1, 1 ]

For historical reasons, QBitArray distinguishes between a null bit array and an empty bit array. A null bit array is a bit array that is initialized using QBitArray's default constructor. An empty bit array is any bit array with size 0. A null bit array is always empty, but an empty bit array isn't necessarily null:

QBitArray().isNull(); // returns true QBitArray().isEmpty(); // returns true

QBitArray(0).isNull(); // returns false QBitArray(0).isEmpty(); // returns true

QBitArray(3).isNull(); // returns false QBitArray(3).isEmpty(); // returns false

All functions except isNull() treat null bit arrays the same as empty bit arrays; for example, QBitArray() compares equal to QBitArray(0). We recommend that you always use isEmpty() and avoid isNull().

Implementations§

source§

impl QBitArray

source

pub unsafe fn at(&self, i: c_int) -> bool

Returns the value of the bit at index position i.

Calls C++ function: bool QBitArray::at(int i) const.

C++ documentation:

Returns the value of the bit at index position i.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also operator[]().

source

pub unsafe fn bit_and_assign( &self, arg1: impl CastInto<Ref<QBitArray>> ) -> Ref<QBitArray>

Performs the AND operation between all bits in this bit array and other. Assigns the result to this bit array, and returns a reference to it.

Calls C++ function: QBitArray& QBitArray::operator&=(const QBitArray& arg1).

C++ documentation:

Performs the AND operation between all bits in this bit array and other. Assigns the result to this bit array, and returns a reference to it.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3); QBitArray b(2); a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ] b[0] = 1; b[1] = 1; // b: [ 1, 1 ] a &= b; // a: [ 1, 0, 0 ]

See also operator&(), operator|=(), operator^=(), and operator~().

source

pub unsafe fn bit_not(&self) -> CppBox<QBitArray>

Returns a bit array that contains the inverted bits of this bit array.

Calls C++ function: QBitArray QBitArray::operator~() const.

C++ documentation:

Returns a bit array that contains the inverted bits of this bit array.

Example:

QBitArray a(3); QBitArray b; a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ] b = ~a; // b: [ 0, 1, 0 ]

See also operator&(), operator|(), and operator^().

source

pub unsafe fn bit_or_assign( &self, arg1: impl CastInto<Ref<QBitArray>> ) -> Ref<QBitArray>

Performs the OR operation between all bits in this bit array and other. Assigns the result to this bit array, and returns a reference to it.

Calls C++ function: QBitArray& QBitArray::operator|=(const QBitArray& arg1).

C++ documentation:

Performs the OR operation between all bits in this bit array and other. Assigns the result to this bit array, and returns a reference to it.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3); QBitArray b(2); a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ] b[0] = 1; b[1] = 1; // b: [ 1, 1 ] a |= b; // a: [ 1, 1, 1 ]

See also operator|(), operator&=(), operator^=(), and operator~().

source

pub unsafe fn bit_xor_assign( &self, arg1: impl CastInto<Ref<QBitArray>> ) -> Ref<QBitArray>

Performs the XOR operation between all bits in this bit array and other. Assigns the result to this bit array, and returns a reference to it.

Calls C++ function: QBitArray& QBitArray::operator^=(const QBitArray& arg1).

C++ documentation:

Performs the XOR operation between all bits in this bit array and other. Assigns the result to this bit array, and returns a reference to it.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3); QBitArray b(2); a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ] b[0] = 1; b[1] = 1; // b: [ 1, 1 ] a ^= b; // a: [ 0, 1, 1 ]

See also operator^(), operator&=(), operator|=(), and operator~().

source

pub unsafe fn bits(&self) -> *const c_char

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns a pointer to a dense bit array for this QBitArray. Bits are counted upwards from the least significant bit in each byte. The the number of bits relevant in the last byte is given by size() % 8.

Calls C++ function: const char* QBitArray::bits() const.

C++ documentation:

Returns a pointer to a dense bit array for this QBitArray. Bits are counted upwards from the least significant bit in each byte. The the number of bits relevant in the last byte is given by size() % 8.

This function was introduced in Qt 5.11.

See also fromBits() and size().

source

pub unsafe fn clear(&self)

Clears the contents of the bit array and makes it empty.

Calls C++ function: void QBitArray::clear().

C++ documentation:

Clears the contents of the bit array and makes it empty.

See also resize() and isEmpty().

source

pub unsafe fn clear_bit(&self, i: c_int)

Sets the bit at index position i to 0.

Calls C++ function: void QBitArray::clearBit(int i).

C++ documentation:

Sets the bit at index position i to 0.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also setBit() and toggleBit().

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QBitArray>> ) -> Ref<QBitArray>

Assigns other to this bit array and returns a reference to this bit array.

Calls C++ function: QBitArray& QBitArray::operator=(const QBitArray& other).

C++ documentation:

Assigns other to this bit array and returns a reference to this bit array.

source

pub unsafe fn count_0a(&self) -> c_int

Same as size().

Calls C++ function: int QBitArray::count() const.

C++ documentation:

Same as size().

source

pub unsafe fn count_1a(&self, on: bool) -> c_int

If on is true, this function returns the number of 1-bits stored in the bit array; otherwise the number of 0-bits is returned.

Calls C++ function: int QBitArray::count(bool on) const.

C++ documentation:

If on is true, this function returns the number of 1-bits stored in the bit array; otherwise the number of 0-bits is returned.

source

pub unsafe fn detach(&self)

Calls C++ function: void QBitArray::detach().

source

pub unsafe fn fill_2a(&self, val: bool, size: c_int) -> bool

Sets every bit in the bit array to value, returning true if successful; otherwise returns false. If size is different from -1 (the default), the bit array is resized to size beforehand.

Calls C++ function: bool QBitArray::fill(bool val, int size = …).

C++ documentation:

Sets every bit in the bit array to value, returning true if successful; otherwise returns false. If size is different from -1 (the default), the bit array is resized to size beforehand.

Example:

QBitArray ba(8); ba.fill(true); // ba: [ 1, 1, 1, 1, 1, 1, 1, 1 ]

ba.fill(false, 2); // ba: [ 0, 0 ]

See also resize().

source

pub unsafe fn fill_3a(&self, val: bool, first: c_int, last: c_int)

This is an overloaded function.

Calls C++ function: void QBitArray::fill(bool val, int first, int last).

C++ documentation:

This is an overloaded function.

Sets bits at index positions begin up to (but not including) end to value.

begin must be a valid index position in the bit array (0 <= begin < size()).

end must be either a valid index position or equal to size(), in which case the fill operation runs until the end of the array (0 <= end <= size()).

Example:

QBitArray ba(4); ba.fill(true, 1, 2); // ba: [ 0, 1, 0, 0 ] ba.fill(true, 1, 3); // ba: [ 0, 1, 1, 0 ] ba.fill(true, 1, 4); // ba: [ 0, 1, 1, 1 ]

source

pub unsafe fn fill_1a(&self, val: bool) -> bool

Sets every bit in the bit array to value, returning true if successful; otherwise returns false. If size is different from -1 (the default), the bit array is resized to size beforehand.

Calls C++ function: bool QBitArray::fill(bool val).

C++ documentation:

Sets every bit in the bit array to value, returning true if successful; otherwise returns false. If size is different from -1 (the default), the bit array is resized to size beforehand.

Example:

QBitArray ba(8); ba.fill(true); // ba: [ 1, 1, 1, 1, 1, 1, 1, 1 ]

ba.fill(false, 2); // ba: [ 0, 0 ]

See also resize().

source

pub unsafe fn from_bits( data: *const c_char, len: c_longlong ) -> CppBox<QBitArray>

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Creates a QBitArray with the dense bit array located at data, with size bits. The byte array at data must be at least size / 8 (rounded up) bytes long.

Calls C++ function: static QBitArray QBitArray::fromBits(const char* data, long long len).

C++ documentation:

Creates a QBitArray with the dense bit array located at data, with size bits. The byte array at data must be at least size / 8 (rounded up) bytes long.

If size is not a multiple of 8, this function will include the lowest size % 8 bits from the last byte in data.

This function was introduced in Qt 5.11.

See also bits().

source

pub unsafe fn index_int_mut(&self, i: c_int) -> CppBox<QBitRef>

Returns the bit at index position i as a modifiable reference.

Calls C++ function: QBitRef QBitArray::operator[](int i).

C++ documentation:

Returns the bit at index position i as a modifiable reference.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

Example:

QBitArray a(3); a[0] = false; a[1] = true; a[2] = a[0] ^ a[1];

The return value is of type QBitRef, a helper class for QBitArray. When you get an object of type QBitRef, you can assign to it, and the assignment will apply to the bit in the QBitArray from which you got the reference.

The functions testBit(), setBit(), and clearBit() are slightly faster.

See also at(), testBit(), setBit(), and clearBit().

source

pub unsafe fn index_int(&self, i: c_int) -> bool

This is an overloaded function.

Calls C++ function: bool QBitArray::operator[](int i) const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn index_uint_mut(&self, i: c_uint) -> CppBox<QBitRef>

This is an overloaded function.

Calls C++ function: QBitRef QBitArray::operator[](unsigned int i).

C++ documentation:

This is an overloaded function.

source

pub unsafe fn index_uint(&self, i: c_uint) -> bool

This is an overloaded function.

Calls C++ function: bool QBitArray::operator[](unsigned int i) const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn is_detached(&self) -> bool

Calls C++ function: bool QBitArray::isDetached() const.

source

pub unsafe fn is_empty(&self) -> bool

Returns true if this bit array has size 0; otherwise returns false.

Calls C++ function: bool QBitArray::isEmpty() const.

C++ documentation:

Returns true if this bit array has size 0; otherwise returns false.

See also size().

source

pub unsafe fn is_null(&self) -> bool

Returns true if this bit array is null; otherwise returns false.

Calls C++ function: bool QBitArray::isNull() const.

C++ documentation:

Returns true if this bit array is null; otherwise returns false.

Example:

QBitArray().isNull(); // returns true QBitArray(0).isNull(); // returns false QBitArray(3).isNull(); // returns false

Qt makes a distinction between null bit arrays and empty bit arrays for historical reasons. For most applications, what matters is whether or not a bit array contains any data, and this can be determined using isEmpty().

See also isEmpty().

source

pub unsafe fn new_0a() -> CppBox<QBitArray>

Constructs an empty bit array.

Calls C++ function: [constructor] void QBitArray::QBitArray().

C++ documentation:

Constructs an empty bit array.

See also isEmpty().

source

pub unsafe fn new_2a(size: c_int, val: bool) -> CppBox<QBitArray>

Constructs a bit array containing size bits. The bits are initialized with value, which defaults to false (0).

Calls C++ function: [constructor] void QBitArray::QBitArray(int size, bool val = …).

C++ documentation:

Constructs a bit array containing size bits. The bits are initialized with value, which defaults to false (0).

source

pub unsafe fn new_1a(size: c_int) -> CppBox<QBitArray>

Constructs a bit array containing size bits. The bits are initialized with value, which defaults to false (0).

Calls C++ function: [constructor] void QBitArray::QBitArray(int size).

C++ documentation:

Constructs a bit array containing size bits. The bits are initialized with value, which defaults to false (0).

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QBitArray>> ) -> CppBox<QBitArray>

Constructs a copy of other.

Calls C++ function: [constructor] void QBitArray::QBitArray(const QBitArray& other).

C++ documentation:

Constructs a copy of other.

This operation takes constant time, because QBitArray is implicitly shared. This makes returning a QBitArray from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

See also operator=().

source

pub unsafe fn resize(&self, size: c_int)

Resizes the bit array to size bits.

Calls C++ function: void QBitArray::resize(int size).

C++ documentation:

Resizes the bit array to size bits.

If size is greater than the current size, the bit array is extended to make it size bits with the extra bits added to the end. The new bits are initialized to false (0).

If size is less than the current size, bits are removed from the end.

See also size().

source

pub unsafe fn set_bit_1a(&self, i: c_int)

Sets the bit at index position i to 1.

Calls C++ function: void QBitArray::setBit(int i).

C++ documentation:

Sets the bit at index position i to 1.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also clearBit() and toggleBit().

source

pub unsafe fn set_bit_2a(&self, i: c_int, val: bool)

This is an overloaded function.

Calls C++ function: void QBitArray::setBit(int i, bool val).

C++ documentation:

This is an overloaded function.

Sets the bit at index position i to value.

source

pub unsafe fn size(&self) -> c_int

Returns the number of bits stored in the bit array.

Calls C++ function: int QBitArray::size() const.

C++ documentation:

Returns the number of bits stored in the bit array.

See also resize().

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QBitArray>>)

Swaps bit array other with this bit array. This operation is very fast and never fails.

Calls C++ function: void QBitArray::swap(QBitArray& other).

C++ documentation:

Swaps bit array other with this bit array. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

source

pub unsafe fn test_bit(&self, i: c_int) -> bool

Returns true if the bit at index position i is 1; otherwise returns false.

Calls C++ function: bool QBitArray::testBit(int i) const.

C++ documentation:

Returns true if the bit at index position i is 1; otherwise returns false.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also setBit() and clearBit().

source

pub unsafe fn toggle_bit(&self, i: c_int) -> bool

Inverts the value of the bit at index position i, returning the previous value of that bit as either true (if it was set) or false (if it was unset).

Calls C++ function: bool QBitArray::toggleBit(int i).

C++ documentation:

Inverts the value of the bit at index position i, returning the previous value of that bit as either true (if it was set) or false (if it was unset).

If the previous value was 0, the new value will be 1. If the previous value was 1, the new value will be 0.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also setBit() and clearBit().

source

pub unsafe fn truncate(&self, pos: c_int)

Truncates the bit array at index position pos.

Calls C++ function: void QBitArray::truncate(int pos).

C++ documentation:

Truncates the bit array at index position pos.

If pos is beyond the end of the array, nothing happens.

See also resize().

Trait Implementations§

source§

impl BitAnd<Ref<QBitArray>> for &QBitArray

source§

fn bitand(self, arg2: Ref<QBitArray>) -> CppBox<QBitArray>

Returns a bit array that is the AND of the bit arrays a1 and a2.

Calls C++ function: QBitArray operator&(const QBitArray& arg1, const QBitArray& arg2).

C++ documentation:

Returns a bit array that is the AND of the bit arrays a1 and a2.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3); QBitArray b(2); QBitArray c; a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ] b[0] = 1; b[1] = 1; // b: [ 1, 1 ] c = a & b; // c: [ 1, 0, 0 ]

See also operator&=(), operator|(), and operator^().

§

type Output = CppBox<QBitArray>

The resulting type after applying the & operator.
source§

impl BitOr<Ref<QBitArray>> for &QBitArray

source§

fn bitor(self, arg2: Ref<QBitArray>) -> CppBox<QBitArray>

Returns a bit array that is the OR of the bit arrays a1 and a2.

Calls C++ function: QBitArray operator|(const QBitArray& arg1, const QBitArray& arg2).

C++ documentation:

Returns a bit array that is the OR of the bit arrays a1 and a2.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3); QBitArray b(2); QBitArray c; a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ] b[0] = 1; b[1] = 1; // b: [ 1, 1 ] c = a | b; // c: [ 1, 1, 1 ]

See also QBitArray::operator|=(), operator&(), and operator^().

§

type Output = CppBox<QBitArray>

The resulting type after applying the | operator.
source§

impl BitXor<Ref<QBitArray>> for &QBitArray

source§

fn bitxor(self, arg2: Ref<QBitArray>) -> CppBox<QBitArray>

Returns a bit array that is the XOR of the bit arrays a1 and a2.

Calls C++ function: QBitArray operator^(const QBitArray& arg1, const QBitArray& arg2).

C++ documentation:

Returns a bit array that is the XOR of the bit arrays a1 and a2.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3); QBitArray b(2); QBitArray c; a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ] b[0] = 1; b[1] = 1; // b: [ 1, 1 ] c = a ^ b; // c: [ 0, 1, 1 ]

See also operator^=(), operator&(), and operator|().

§

type Output = CppBox<QBitArray>

The resulting type after applying the ^ operator.
source§

impl CppDeletable for QBitArray

source§

unsafe fn delete(&self)

The QBitArray class provides an array of bits.

Calls C++ function: [destructor] void QBitArray::~QBitArray().

C++ documentation:

The QBitArray class provides an array of bits.

A QBitArray is an array that gives access to individual bits and provides operators (AND, OR, XOR, and NOT) that work on entire arrays of bits. It uses implicit sharing (copy-on-write) to reduce memory usage and to avoid the needless copying of data.

The following code constructs a QBitArray containing 200 bits initialized to false (0):

QBitArray ba(200);

To initialize the bits to true, either pass true as second argument to the constructor, or call fill() later on.

QBitArray uses 0-based indexes, just like C++ arrays. To access the bit at a particular index position, you can use operator[](). On non-const bit arrays, operator[]() returns a reference to a bit that can be used on the left side of an assignment. For example:

QBitArray ba; ba.resize(3); ba[0] = true; ba[1] = false; ba[2] = true;

For technical reasons, it is more efficient to use testBit() and setBit() to access bits in the array than operator[](). For example:

QBitArray ba(3); ba.setBit(0, true); ba.setBit(1, false); ba.setBit(2, true);

QBitArray supports & (AND), | (OR), ^ (XOR), ~ (NOT), as well as &=, |=, and ^=. These operators work in the same way as the built-in C++ bitwise operators of the same name. For example:

QBitArray x(5); x.setBit(3, true); // x: [ 0, 0, 0, 1, 0 ]

QBitArray y(5); y.setBit(4, true); // y: [ 0, 0, 0, 0, 1 ]

x |= y; // x: [ 0, 0, 0, 1, 1 ]

For historical reasons, QBitArray distinguishes between a null bit array and an empty bit array. A null bit array is a bit array that is initialized using QBitArray's default constructor. An empty bit array is any bit array with size 0. A null bit array is always empty, but an empty bit array isn't necessarily null:

QBitArray().isNull(); // returns true QBitArray().isEmpty(); // returns true

QBitArray(0).isNull(); // returns false QBitArray(0).isEmpty(); // returns true

QBitArray(3).isNull(); // returns false QBitArray(3).isEmpty(); // returns false

All functions except isNull() treat null bit arrays the same as empty bit arrays; for example, QBitArray() compares equal to QBitArray(0). We recommend that you always use isEmpty() and avoid isNull().

source§

impl PartialEq<Ref<QBitArray>> for QBitArray

source§

fn eq(&self, other: &Ref<QBitArray>) -> bool

Returns true if other is equal to this bit array; otherwise returns false.

Calls C++ function: bool QBitArray::operator==(const QBitArray& other) const.

C++ documentation:

Returns true if other is equal to this bit array; otherwise returns false.

See also operator!=().

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Size for QBitArray

source§

unsafe fn size(&self) -> usize

Returns the number of bits stored in the bit array.

Calls C++ function: int QBitArray::size() const.

C++ documentation:

Returns the number of bits stored in the bit array.

See also resize().

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.