Struct screeps::pathfinder::LocalCostMatrix [−][src]
Implementations
impl LocalCostMatrix
[src]
pub fn new() -> Self
[src]
pub fn set(&mut self, x: u8, y: u8, val: u8)
[src]
pub fn get(&self, x: u8, y: u8) -> u8
[src]
pub fn upload(&self) -> CostMatrix<'static>
[src]
Copies all data into an JavaScript CostMatrix for use.
This is slower than as_uploaded
, but much safer.
pub unsafe fn as_uploaded<'a>(&'a self) -> CostMatrix<'a>
[src]
Temporarily exposes the bits of this matrix as a cost matrix.
Unsafety
There are two main invariants you must uphold after using this function:
-
The
CostMatrix
can only be used in JS code as long as thisLocalCostMatrix
is alive. Doing otherwise will result in undefined behavior, mainly JS being allowed to read/ manipulate uninitialized rust memory or rust memory that's been repurposed. -
The
set
method of the cost matrix must not be used - it must be read only. This takes &self, but technically allows mutation of the inner Vec via JavaScript access. You should not use this method, or you will invoke Rust undefined behavior.
The CostMatrix returned will reference the internal data of this
LocalCostMatrix
.
Trait Implementations
impl Clone for LocalCostMatrix
[src]
fn clone(&self) -> LocalCostMatrix
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> CostMatrixSet for LocalCostMatrix
[src]
fn set_multi<D, B, P, V>(&mut self, data: D) where
D: IntoIterator<Item = B>,
B: Borrow<(P, V)>,
P: HasLocalPosition,
V: Borrow<u8>,
[src]
D: IntoIterator<Item = B>,
B: Borrow<(P, V)>,
P: HasLocalPosition,
V: Borrow<u8>,
fn set<P, V>(&mut self, position: P, cost: V) where
P: HasLocalPosition,
V: Borrow<u8>,
[src]
P: HasLocalPosition,
V: Borrow<u8>,
impl Debug for LocalCostMatrix
[src]
impl Default for LocalCostMatrix
[src]
impl<'de> Deserialize<'de> for LocalCostMatrix
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Into<Vec<u8, Global>> for LocalCostMatrix
[src]
fn into(self) -> Vec<u8>
[src]
Returns a vector of bits length 2500, where each position is
idx = ((x * 50) + y)
.
impl Serialize for LocalCostMatrix
[src]
Auto Trait Implementations
impl RefUnwindSafe for LocalCostMatrix
[src]
impl Send for LocalCostMatrix
[src]
impl Sync for LocalCostMatrix
[src]
impl Unpin for LocalCostMatrix
[src]
impl UnwindSafe for LocalCostMatrix
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> IntoExpectedType<U> for T where
U: FromExpectedType<T>,
[src]
U: FromExpectedType<T>,
pub fn into_expected_type(Self) -> Result<U, ConversionError>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,