Fix clippy warnings: passed by reference, but would be more efficient if passed by value

https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref

i = 0
ll = map(lambda x: int(x.strip()), file("/tmp/lines").readlines())
ll2 = map(lambda x: int(x.strip()), file("/tmp/lines2").readlines())
for line in file("/Users/admin/games/rust/steven/blocks/src/lib.rs").readlines():
    i += 1
    line = line[:-1]

    if i in ll:
        line = line.replace("&self", "self")

    if i in ll2:
        line = line.replace("*self", "self")

    print line
This commit is contained in:
ice_iix 2018-11-04 14:31:46 -08:00
parent ca14ea595b
commit b4514a8500
1 changed files with 100 additions and 100 deletions

View File

@ -4272,8 +4272,8 @@ pub enum StoneVariant {
} }
impl StoneVariant { impl StoneVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
StoneVariant::Normal => "stone", StoneVariant::Normal => "stone",
StoneVariant::Granite => "granite", StoneVariant::Granite => "granite",
StoneVariant::SmoothGranite => "smooth_granite", StoneVariant::SmoothGranite => "smooth_granite",
@ -4283,8 +4283,8 @@ impl StoneVariant {
StoneVariant::SmoothAndesite => "smooth_andesite", StoneVariant::SmoothAndesite => "smooth_andesite",
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
StoneVariant::Normal => 0, StoneVariant::Normal => 0,
StoneVariant::Granite => 1, StoneVariant::Granite => 1,
StoneVariant::SmoothGranite => 2, StoneVariant::SmoothGranite => 2,
@ -4304,16 +4304,16 @@ pub enum DirtVariant {
} }
impl DirtVariant { impl DirtVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
DirtVariant::Normal => "dirt", DirtVariant::Normal => "dirt",
DirtVariant::Coarse => "coarse_dirt", DirtVariant::Coarse => "coarse_dirt",
DirtVariant::Podzol => "podzol", DirtVariant::Podzol => "podzol",
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
DirtVariant::Normal => 0, DirtVariant::Normal => 0,
DirtVariant::Coarse => 1, DirtVariant::Coarse => 1,
DirtVariant::Podzol => 2, DirtVariant::Podzol => 2,
@ -4328,8 +4328,8 @@ pub enum BedPart {
} }
impl BedPart { impl BedPart {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
BedPart::Head => "head", BedPart::Head => "head",
BedPart::Foot => "foot", BedPart::Foot => "foot",
} }
@ -4344,16 +4344,16 @@ pub enum SandstoneVariant {
} }
impl SandstoneVariant { impl SandstoneVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
SandstoneVariant::Normal => "sandstone", SandstoneVariant::Normal => "sandstone",
SandstoneVariant::Chiseled => "chiseled_sandstone", SandstoneVariant::Chiseled => "chiseled_sandstone",
SandstoneVariant::Smooth => "smooth_sandstone", SandstoneVariant::Smooth => "smooth_sandstone",
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
SandstoneVariant::Normal => 0, SandstoneVariant::Normal => 0,
SandstoneVariant::Chiseled => 1, SandstoneVariant::Chiseled => 1,
SandstoneVariant::Smooth => 2, SandstoneVariant::Smooth => 2,
@ -4369,16 +4369,16 @@ pub enum RedSandstoneVariant {
} }
impl RedSandstoneVariant { impl RedSandstoneVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
RedSandstoneVariant::Normal => "red_sandstone", RedSandstoneVariant::Normal => "red_sandstone",
RedSandstoneVariant::Chiseled => "chiseled_red_sandstone", RedSandstoneVariant::Chiseled => "chiseled_red_sandstone",
RedSandstoneVariant::Smooth => "smooth_red_sandstone", RedSandstoneVariant::Smooth => "smooth_red_sandstone",
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
RedSandstoneVariant::Normal => 0, RedSandstoneVariant::Normal => 0,
RedSandstoneVariant::Chiseled => 1, RedSandstoneVariant::Chiseled => 1,
RedSandstoneVariant::Smooth => 2, RedSandstoneVariant::Smooth => 2,
@ -4396,8 +4396,8 @@ pub enum QuartzVariant {
} }
impl QuartzVariant { impl QuartzVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
QuartzVariant::Normal | QuartzVariant::Chiseled => "normal", QuartzVariant::Normal | QuartzVariant::Chiseled => "normal",
QuartzVariant::PillarVertical => "axis=y", QuartzVariant::PillarVertical => "axis=y",
QuartzVariant::PillarNorthSouth => "axis=z", QuartzVariant::PillarNorthSouth => "axis=z",
@ -4405,8 +4405,8 @@ impl QuartzVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
QuartzVariant::Normal => 0, QuartzVariant::Normal => 0,
QuartzVariant::Chiseled => 1, QuartzVariant::Chiseled => 1,
QuartzVariant::PillarVertical => 2, QuartzVariant::PillarVertical => 2,
@ -4424,16 +4424,16 @@ pub enum PrismarineVariant {
} }
impl PrismarineVariant { impl PrismarineVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
PrismarineVariant::Normal => "prismarine", PrismarineVariant::Normal => "prismarine",
PrismarineVariant::Brick => "prismarine_bricks", PrismarineVariant::Brick => "prismarine_bricks",
PrismarineVariant::Dark => "dark_prismarine", PrismarineVariant::Dark => "dark_prismarine",
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
PrismarineVariant::Normal => 0, PrismarineVariant::Normal => 0,
PrismarineVariant::Brick => 1, PrismarineVariant::Brick => 1,
PrismarineVariant::Dark => 2, PrismarineVariant::Dark => 2,
@ -4459,8 +4459,8 @@ pub enum MushroomVariant {
} }
impl MushroomVariant { impl MushroomVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
MushroomVariant::East => "east", MushroomVariant::East => "east",
MushroomVariant::North => "north", MushroomVariant::North => "north",
MushroomVariant::NorthEast => "north_east", MushroomVariant::NorthEast => "north_east",
@ -4477,8 +4477,8 @@ impl MushroomVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
MushroomVariant::AllInside => 0, MushroomVariant::AllInside => 0,
MushroomVariant::NorthWest => 1, MushroomVariant::NorthWest => 1,
MushroomVariant::North => 2, MushroomVariant::North => 2,
@ -4503,8 +4503,8 @@ pub enum DoorHalf {
} }
impl DoorHalf { impl DoorHalf {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
DoorHalf::Upper => "upper", DoorHalf::Upper => "upper",
DoorHalf::Lower => "lower", DoorHalf::Lower => "lower",
} }
@ -4518,8 +4518,8 @@ pub enum Side {
} }
impl Side { impl Side {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
Side::Left => "left", Side::Left => "left",
Side::Right => "right", Side::Right => "right",
} }
@ -4547,8 +4547,8 @@ pub enum ColoredVariant {
} }
impl ColoredVariant { impl ColoredVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
ColoredVariant::White => "white", ColoredVariant::White => "white",
ColoredVariant::Orange => "orange", ColoredVariant::Orange => "orange",
ColoredVariant::Magenta => "magenta", ColoredVariant::Magenta => "magenta",
@ -4568,8 +4568,8 @@ impl ColoredVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
ColoredVariant::White => 0, ColoredVariant::White => 0,
ColoredVariant::Orange => 1, ColoredVariant::Orange => 1,
ColoredVariant::Magenta => 2, ColoredVariant::Magenta => 2,
@ -4604,8 +4604,8 @@ pub enum RedFlowerVariant {
} }
impl RedFlowerVariant { impl RedFlowerVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
RedFlowerVariant::Poppy => "poppy", RedFlowerVariant::Poppy => "poppy",
RedFlowerVariant::BlueOrchid => "blue_orchid", RedFlowerVariant::BlueOrchid => "blue_orchid",
RedFlowerVariant::Allium => "allium", RedFlowerVariant::Allium => "allium",
@ -4618,8 +4618,8 @@ impl RedFlowerVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
RedFlowerVariant::Poppy => 0, RedFlowerVariant::Poppy => 0,
RedFlowerVariant::BlueOrchid => 1, RedFlowerVariant::BlueOrchid => 1,
RedFlowerVariant::Allium => 2, RedFlowerVariant::Allium => 2,
@ -4644,8 +4644,8 @@ pub enum MonsterEggVariant {
} }
impl MonsterEggVariant { impl MonsterEggVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
MonsterEggVariant::Stone => "stone", MonsterEggVariant::Stone => "stone",
MonsterEggVariant::Cobblestone => "cobblestone", MonsterEggVariant::Cobblestone => "cobblestone",
MonsterEggVariant::StoneBrick => "stone_brick", MonsterEggVariant::StoneBrick => "stone_brick",
@ -4655,8 +4655,8 @@ impl MonsterEggVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
MonsterEggVariant::Stone => 0, MonsterEggVariant::Stone => 0,
MonsterEggVariant::Cobblestone => 1, MonsterEggVariant::Cobblestone => 1,
MonsterEggVariant::StoneBrick => 2, MonsterEggVariant::StoneBrick => 2,
@ -4676,8 +4676,8 @@ pub enum StoneBrickVariant {
} }
impl StoneBrickVariant { impl StoneBrickVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
StoneBrickVariant::Normal => "stonebrick", StoneBrickVariant::Normal => "stonebrick",
StoneBrickVariant::Mossy => "mossy_stonebrick", StoneBrickVariant::Mossy => "mossy_stonebrick",
StoneBrickVariant::Cracked => "cracked_stonebrick", StoneBrickVariant::Cracked => "cracked_stonebrick",
@ -4685,8 +4685,8 @@ impl StoneBrickVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
StoneBrickVariant::Normal => 0, StoneBrickVariant::Normal => 0,
StoneBrickVariant::Mossy => 1, StoneBrickVariant::Mossy => 1,
StoneBrickVariant::Cracked => 2, StoneBrickVariant::Cracked => 2,
@ -4710,8 +4710,8 @@ pub enum RailShape {
} }
impl RailShape { impl RailShape {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
RailShape::NorthSouth => "north_south", RailShape::NorthSouth => "north_south",
RailShape::EastWest => "east_west", RailShape::EastWest => "east_west",
RailShape::AscendingNorth => "ascending_north", RailShape::AscendingNorth => "ascending_north",
@ -4725,8 +4725,8 @@ impl RailShape {
} }
} }
pub fn data(&self) -> usize { pub fn data(self) -> usize {
match *self { match self {
RailShape::NorthSouth => 0, RailShape::NorthSouth => 0,
RailShape::EastWest => 1, RailShape::EastWest => 1,
RailShape::AscendingEast => 2, RailShape::AscendingEast => 2,
@ -4748,8 +4748,8 @@ pub enum ComparatorMode {
} }
impl ComparatorMode { impl ComparatorMode {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
ComparatorMode::Compare => "compare", ComparatorMode::Compare => "compare",
ComparatorMode::Subtract => "subtract", ComparatorMode::Subtract => "subtract",
} }
@ -4769,8 +4769,8 @@ pub enum LeverDirection {
} }
impl LeverDirection { impl LeverDirection {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
LeverDirection::North => "north", LeverDirection::North => "north",
LeverDirection::South => "south", LeverDirection::South => "south",
LeverDirection::East => "east", LeverDirection::East => "east",
@ -4782,8 +4782,8 @@ impl LeverDirection {
} }
} }
pub fn data(&self) -> usize { pub fn data(self) -> usize {
match *self { match self {
LeverDirection::DownX => 0, LeverDirection::DownX => 0,
LeverDirection::East => 1, LeverDirection::East => 1,
LeverDirection::West => 2, LeverDirection::West => 2,
@ -4804,8 +4804,8 @@ pub enum RedstoneSide {
} }
impl RedstoneSide { impl RedstoneSide {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
RedstoneSide::None => "none", RedstoneSide::None => "none",
RedstoneSide::Side => "side", RedstoneSide::Side => "side",
RedstoneSide::Up => "up", RedstoneSide::Up => "up",
@ -4820,8 +4820,8 @@ pub enum PistonType {
} }
impl PistonType { impl PistonType {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
PistonType::Normal => "normal", PistonType::Normal => "normal",
PistonType::Sticky => "sticky", PistonType::Sticky => "sticky",
} }
@ -4843,8 +4843,8 @@ pub enum StoneSlabVariant {
} }
impl StoneSlabVariant { impl StoneSlabVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
StoneSlabVariant::Stone => "stone", StoneSlabVariant::Stone => "stone",
StoneSlabVariant::Sandstone => "sandstone", StoneSlabVariant::Sandstone => "sandstone",
StoneSlabVariant::Wood => "wood_old", StoneSlabVariant::Wood => "wood_old",
@ -4858,8 +4858,8 @@ impl StoneSlabVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
StoneSlabVariant::Stone | StoneSlabVariant::Stone |
StoneSlabVariant::RedSandstone | StoneSlabVariant::RedSandstone |
StoneSlabVariant::Purpur => 0, StoneSlabVariant::Purpur => 0,
@ -4885,8 +4885,8 @@ pub enum WoodSlabVariant {
} }
impl WoodSlabVariant { impl WoodSlabVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
WoodSlabVariant::Oak => "oak", WoodSlabVariant::Oak => "oak",
WoodSlabVariant::Spruce => "spruce", WoodSlabVariant::Spruce => "spruce",
WoodSlabVariant::Birch => "birch", WoodSlabVariant::Birch => "birch",
@ -4896,8 +4896,8 @@ impl WoodSlabVariant {
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
WoodSlabVariant::Oak => 0, WoodSlabVariant::Oak => 0,
WoodSlabVariant::Spruce => 1, WoodSlabVariant::Spruce => 1,
WoodSlabVariant::Birch => 2, WoodSlabVariant::Birch => 2,
@ -4917,8 +4917,8 @@ pub enum BlockHalf {
} }
impl BlockHalf { impl BlockHalf {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
BlockHalf::Top => "top", BlockHalf::Top => "top",
BlockHalf::Bottom => "bottom", BlockHalf::Bottom => "bottom",
BlockHalf::Upper => "upper", BlockHalf::Upper => "upper",
@ -4934,15 +4934,15 @@ pub enum CobblestoneWallVariant {
} }
impl CobblestoneWallVariant { impl CobblestoneWallVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
CobblestoneWallVariant::Normal => "cobblestone", CobblestoneWallVariant::Normal => "cobblestone",
CobblestoneWallVariant::Mossy => "mossy_cobblestone", CobblestoneWallVariant::Mossy => "mossy_cobblestone",
} }
} }
pub fn data(&self) -> usize { pub fn data(self) -> usize {
match *self { match self {
CobblestoneWallVariant::Normal => 0, CobblestoneWallVariant::Normal => 0,
CobblestoneWallVariant::Mossy => 1, CobblestoneWallVariant::Mossy => 1,
} }
@ -4970,8 +4970,8 @@ pub enum Rotation {
} }
impl Rotation { impl Rotation {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
Rotation::South => "south", Rotation::South => "south",
Rotation::SouthSouthWest => "south-southwest", Rotation::SouthSouthWest => "south-southwest",
Rotation::SouthWest => "southwest", Rotation::SouthWest => "southwest",
@ -4991,8 +4991,8 @@ impl Rotation {
} }
} }
pub fn data(&self) -> usize { pub fn data(self) -> usize {
match *self { match self {
Rotation::South => 0, Rotation::South => 0,
Rotation::SouthSouthWest => 1, Rotation::SouthSouthWest => 1,
Rotation::SouthWest => 2, Rotation::SouthWest => 2,
@ -5023,8 +5023,8 @@ pub enum StairShape {
} }
impl StairShape { impl StairShape {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
StairShape::Straight => "straight", StairShape::Straight => "straight",
StairShape::InnerLeft => "inner_left", StairShape::InnerLeft => "inner_left",
StairShape::InnerRight => "inner_right", StairShape::InnerRight => "inner_right",
@ -5046,8 +5046,8 @@ pub enum TreeVariant {
} }
impl TreeVariant { impl TreeVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
TreeVariant::Oak => "oak", TreeVariant::Oak => "oak",
TreeVariant::Spruce => "spruce", TreeVariant::Spruce => "spruce",
TreeVariant::Birch => "birch", TreeVariant::Birch => "birch",
@ -5057,8 +5057,8 @@ impl TreeVariant {
} }
} }
pub fn data(&self) -> usize { pub fn data(self) -> usize {
match *self { match self {
TreeVariant::Oak | TreeVariant::Acacia => 0, TreeVariant::Oak | TreeVariant::Acacia => 0,
TreeVariant::Spruce | TreeVariant::DarkOak => 1, TreeVariant::Spruce | TreeVariant::DarkOak => 1,
TreeVariant::Birch => 2, TreeVariant::Birch => 2,
@ -5066,8 +5066,8 @@ impl TreeVariant {
} }
} }
pub fn plank_data(&self) -> usize { pub fn plank_data(self) -> usize {
match *self { match self {
TreeVariant::Oak => 0, TreeVariant::Oak => 0,
TreeVariant::Spruce => 1, TreeVariant::Spruce => 1,
TreeVariant::Birch => 2, TreeVariant::Birch => 2,
@ -5086,16 +5086,16 @@ pub enum TallGrassVariant {
} }
impl TallGrassVariant { impl TallGrassVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
TallGrassVariant::DeadBush => "dead_bush", TallGrassVariant::DeadBush => "dead_bush",
TallGrassVariant::TallGrass => "tall_grass", TallGrassVariant::TallGrass => "tall_grass",
TallGrassVariant::Fern => "fern", TallGrassVariant::Fern => "fern",
} }
} }
fn data(&self) -> usize { fn data(self) -> usize {
match *self { match self {
TallGrassVariant::DeadBush => 0, TallGrassVariant::DeadBush => 0,
TallGrassVariant::TallGrass => 1, TallGrassVariant::TallGrass => 1,
TallGrassVariant::Fern => 2, TallGrassVariant::Fern => 2,
@ -5114,8 +5114,8 @@ pub enum DoublePlantVariant {
} }
impl DoublePlantVariant { impl DoublePlantVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
DoublePlantVariant::Sunflower => "sunflower", DoublePlantVariant::Sunflower => "sunflower",
DoublePlantVariant::Lilac => "syringa", DoublePlantVariant::Lilac => "syringa",
DoublePlantVariant::DoubleTallgrass => "double_grass", DoublePlantVariant::DoubleTallgrass => "double_grass",
@ -5125,8 +5125,8 @@ impl DoublePlantVariant {
} }
} }
pub fn data(&self) -> usize { pub fn data(self) -> usize {
match *self { match self {
DoublePlantVariant::Sunflower => 0, DoublePlantVariant::Sunflower => 0,
DoublePlantVariant::Lilac => 1, DoublePlantVariant::Lilac => 1,
DoublePlantVariant::DoubleTallgrass => 2, DoublePlantVariant::DoubleTallgrass => 2,
@ -5164,8 +5164,8 @@ pub enum FlowerPotVariant {
} }
impl FlowerPotVariant { impl FlowerPotVariant {
pub fn as_string(&self) -> &'static str { pub fn as_string(self) -> &'static str {
match *self { match self {
FlowerPotVariant::Empty => "empty", FlowerPotVariant::Empty => "empty",
FlowerPotVariant::Poppy => "rose", FlowerPotVariant::Poppy => "rose",
FlowerPotVariant::Dandelion => "dandelion", FlowerPotVariant::Dandelion => "dandelion",