[−][src]Struct patch::Patch
A complete patch summarizing the differences between two files
Fields
old: File<'a>
The file information of the -
side of the diff, line prefix: ---
new: File<'a>
The file information of the +
side of the diff, line prefix: +++
hunks: Vec<Hunk<'a>>
hunks of differences; each hunk shows one area where the files differ
end_newline: bool
true if the last line of the file ends in a newline character
This will only be false if at the end of the patch we encounter the text:
\ No newline at end of file
Methods
impl<'a> Patch<'a>
[src]
pub fn from_single(s: &'a str) -> Result<Self, ParseError<'a>>
[src]
Attempt to parse a patch from the given string.
Example
let sample = "\ --- lao 2002-02-21 23:30:39.942229878 -0800 +++ tzu 2002-02-21 23:30:50.442260588 -0800 @@ -1,7 +1,6 @@ -The Way that can be told of is not the eternal Way; -The name that can be named is not the eternal name. The Nameless is the origin of Heaven and Earth; -The Named is the mother of all things. +The named is the mother of all things. + Therefore let there always be non-being, so we may see their subtlety, And let there always be being, @@ -9,3 +8,6 @@ The two are the same, But after they are produced, they have different names. +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! \\ No newline at end of file\n"; let patch = Patch::from_single(sample)?; assert_eq!(&patch.old.path, "lao"); assert_eq!(&patch.new.path, "tzu"); assert_eq!(patch.end_newline, false);
pub fn from_multiple(s: &'a str) -> Result<Vec<Self>, ParseError<'a>>
[src]
Attempt to parse as many patches as possible from the given string. This is useful for when you have a complete diff of many files. String must contain at least one patch.
Example
let sample = "\ diff --git a/src/generator/place_items.rs b/src/generator/place_items.rs index 508f4e9..31a167e 100644 --- a/src/generator/place_items.rs +++ b/src/generator/place_items.rs @@ -233,7 +233,7 @@ impl<'a> GameGenerator<'a> { // oooooooo // // x would pass all of the previous checks but get caught by this one - if grid.adjacent_positions(inner_room_tile).find(|&pt| grid.is_room_entrance(pt)).is_some() { + if grid.adjacent_positions(inner_room_tile).any(|&pt| grid.is_room_entrance(pt)) { return None; } diff --git a/src/ui/level_screen.rs b/src/ui/level_screen.rs index 81fe540..166bb2b 100644 --- a/src/ui/level_screen.rs +++ b/src/ui/level_screen.rs @@ -48,7 +48,7 @@ impl<'a, 'b> LevelScreen<'a, 'b> { // Find the empty position adjacent to this staircase. There should only be one. let map = self.world.read_resource::<FloorMap>(); let tile_pos = map.world_to_tile_pos(pos); - let empty = map.grid().adjacent_positions(tile_pos).find(|&p| !map.grid().get(p).is_wall()) + let empty = map.grid().adjacents(tile_pos).find(|t| !t.is_wall()) .expect(\"bug: should be one empty position adjacent to a staircase\"); empty.center(map.tile_size() as i32) } @@ -64,7 +64,7 @@ impl<'a, 'b> LevelScreen<'a, 'b> { // Find the empty position adjacent to this staircase. There should only be one. let map = self.world.read_resource::<FloorMap>(); let tile_pos = map.world_to_tile_pos(pos); - let empty = map.grid().adjacent_positions(tile_pos).find(|&p| !map.grid().get(p).is_wall()) + let empty = map.grid().adjacents(tile_pos).find(|t| !t.is_wall()) .expect(\"bug: should be one empty position adjacent to a staircase\"); empty.center(map.tile_size() as i32) }\n"; let patches = Patch::from_multiple(sample)?; assert_eq!(patches.len(), 2);
Trait Implementations
impl<'a> Eq for Patch<'a>
[src]
impl<'a> Clone for Patch<'a>
[src]
fn clone(&self) -> Patch<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> PartialEq<Patch<'a>> for Patch<'a>
[src]
impl<'a> Debug for Patch<'a>
[src]
impl<'a> Display for Patch<'a>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,