1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
//! Operator traits not present in Rust's `std` //! //! See also `cpp_core::cmp` for comparison operator traits. // TODO: `&mut self` for increment and decrement? /// Represents C++'s prefix increment (`++a`). pub trait Increment { /// Output type. type Output; /// Increment `self`. /// /// # Safety /// /// The caller must make sure `self` contains a valid pointer. This function /// may invoke arbitrary foreign code, so no safety guarantees can be made. unsafe fn inc(&self) -> Self::Output; } /// Represents C++'s prefix decrement (`--a`). pub trait Decrement { /// Output type. type Output; /// Decrement `self`. /// /// # Safety /// /// The caller must make sure `self` contains a valid pointer. This function /// may invoke arbitrary foreign code, so no safety guarantees can be made. unsafe fn dec(&self) -> Self::Output; } /// Represents C++'s indirection operator (`*a`). pub trait Indirection { /// Output type. type Output; /// Returns the object `self` is pointing to. /// /// # Safety /// /// The caller must make sure `self` contains a valid pointer. This function /// may invoke arbitrary foreign code, so no safety guarantees can be made. unsafe fn indirection(&self) -> Self::Output; } /// Represents C++'s `begin() const` function. pub trait Begin { /// Output type. type Output; /// Returns a C++ const iterator object pointing to the beginning of the collection. /// /// # Safety /// /// The caller must make sure `self` contains a valid pointer. This function /// may invoke arbitrary foreign code, so no safety guarantees can be made. unsafe fn begin(&self) -> Self::Output; } /// Represents C++'s `begin()` function. pub trait BeginMut { /// Output type. type Output; /// Returns a C++ mutable iterator object pointing to the beginning of the collection. /// /// # Safety /// /// The caller must make sure `self` contains a valid pointer. This function /// may invoke arbitrary foreign code, so no safety guarantees can be made. unsafe fn begin_mut(&self) -> Self::Output; } /// Represents C++'s `end() const` function. pub trait End { /// Output type. type Output; /// Returns a C++ const iterator object pointing to the end of the collection. /// /// # Safety /// /// The caller must make sure `self` contains a valid pointer. This function /// may invoke arbitrary foreign code, so no safety guarantees can be made. unsafe fn end(&self) -> Self::Output; } /// Represents C++'s `end()` function. pub trait EndMut { /// Output type. type Output; /// Returns a C++ mutable iterator object pointing to the end of the collection. /// /// # Safety /// /// The caller must make sure `self` contains a valid pointer. This function /// may invoke arbitrary foreign code, so no safety guarantees can be made. unsafe fn end_mut(&self) -> Self::Output; }