Skip to content

Commit

Permalink
clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Odilf committed Aug 12, 2023
1 parent 810e2b7 commit dcd4c6b
Show file tree
Hide file tree
Showing 28 changed files with 79 additions and 80 deletions.
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/cube2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod test;

/// The 2x2x2 cube.
///
/// See [crate::cube_n] for more info.
/// See [`crate::cube_n`] for more info.
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub struct Cube2 {
/// Corners of the 2x2x2 cube (actually, it's the only piece type it has).
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/cube3/heuristics/mus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn mus_with_fallback(fallback: impl Fn(&Cube3) -> f32) -> impl Fn(&Cube3) ->
/// Returns the maximum of the number of moves it takes to
/// solve the corners and the two sets of 6 edges.
///
/// See also [crate::cube3::mus].
/// See also [`crate::cube3::mus`].
pub fn mus(cube: &Cube3) -> f32 {
mus::cache::get_or_init(cube) as f32
}
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/cube3/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The 3x3x3 Rubik's cube.
//!
//! See [Cube3] and [cube_n](crate::cube_n) for more information.
//! See [Cube3] and [`cube_n`](crate::cube_n) for more information.

pub mod heuristics;
pub mod mus;
Expand Down
4 changes: 2 additions & 2 deletions barbarosa/src/cube_n/cube3/mus/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ pub trait OrientationIndexable {

/// Trait for indexing. Every unique instance of a type that implements this trait has to return a
/// unique index, and all indices have to be contiguous (starting from 0). In other words, you can index
/// into an array of size [Self::TOTAL_SET_SIZE] with the index returned by [Self::index()].
/// into an array of size [`Self::TOTAL_SET_SIZE`] with the index returned by [`Self::index`()].
///
/// This type requires and is auto-implemented with [PositionIndexable] and [OrientationIndexable]
/// This type requires and is auto-implemented with [`PositionIndexable`] and [`OrientationIndexable`]
// TODO: Write about the implementation
pub trait Indexable: PositionIndexable + OrientationIndexable {
/// Returns the index of the instance. See [Indexable] for more info.
Expand Down
4 changes: 2 additions & 2 deletions barbarosa/src/cube_n/cube3/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ fn solved_cube_has_pieces_in_all_coordinates() {
let mut positions: HashSet<_> = solved_cube
.edges
.pieces()
.into_iter()
.iter()
.map(|piece| piece.coordinates().map(|i| i as i32))
.collect();

positions.extend(
solved_cube
.corners
.pieces()
.into_iter()
.iter()
.map(|piece| piece.coordinates().map(|i| i as i32)),
);

Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/cube4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{

/// The 4x4x4 cube.
///
/// See [crate::cube_n] for more info.
/// See [`crate::cube_n`] for more info.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Cube4 {
corners: CornerSet,
Expand Down
5 changes: 2 additions & 3 deletions barbarosa/src/cube_n/cube4/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ fn four_wide_fs() {
for i in 0..4 {
cube.apply(&mov);

match i {
0 => expect_wing(&cube, ([R, F], Positive), ([U, F], Negative)),
_ => (),
if i == 0 {
expect_wing(&cube, ([R, F], Positive), ([U, F], Negative));
}
}

Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/cube5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::{

/// The 5x5x5 cube.
///
/// See [crate::cube_n] for more info.
/// See [`crate::cube_n`] for more info.
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Cube5 {
corners: CornerSet,
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/cube6/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{

/// The 6x6x6 cube.
///
/// See [crate::cube_n] for more info.
/// See [`crate::cube_n`] for more info.
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Cube6 {
corners: CornerSet,
Expand Down
4 changes: 2 additions & 2 deletions barbarosa/src/cube_n/cube7/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use super::{
CubeN, WideAxisMove,
};

/// The 7x7x7 cube. The biggest [WCA](https://www.worldcubeassociation.org/) NxN.
/// The 7x7x7 cube. The biggest [WCA](https://www.worldcubeassociation.org/) `NxN`.
///
/// See [crate::cube_n] for more info.
/// See [`crate::cube_n`] for more info.
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Cube7 {
corners: CornerSet,
Expand Down
6 changes: 3 additions & 3 deletions barbarosa/src/cube_n/invariants.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Collection of functions to assert if cube invariants are upheld and to fix them.
//!
//! TODO: This docs are written for a 3x3x3 cube, but they should be valid for any NxNxN cube.
//! TODO: This docs are written for a 3x3x3 cube, but they should be valid for any `NxNxN` cube.
//!
//! Mainly used for [Cube::random()](rand::random::<Cube3>())
//! Mainly used for [`Cube::random`()](rand::random::<Cube3>())
//!
//! There are thre invariants we need to uphold in a 3x3x3 Rubik's cube. We can deduce them by analizing what
//! a single move does in terms of swaps and changes of orientation.
Expand All @@ -26,7 +26,7 @@
//! - Twisting `cube.corners[7]` such that the sum of corner orientation indices is divisble by 3.
//!
//! PS: The reason to change the orientation of the last piece is because it makes implementing
//! [mus::index::OrientationIndexable](super::cube3::mus::index::OrientationIndexable) nicer for corners.
//! [`mus::index::OrientationIndexable`](super::cube3::mus::index::OrientationIndexable) nicer for corners.

use std::fmt::Debug;

Expand Down
12 changes: 6 additions & 6 deletions barbarosa/src/cube_n/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! NxNxNs cube implementation.
//! `NxNxNs` cube implementation.
//!
//! See [crate::generic] for more aspects that are generic across all cubes, such as moves and pieces.
//! See [`crate::generic`] for more aspects that are generic across all cubes, such as moves and pieces.
//!
//! # Piece position
//!
Expand All @@ -10,10 +10,10 @@
//! the color of, for example, a corner just by the information in the [Corner] struct.
//!
//! Rather, the cube is responsible for keeping track for which piece is which. Simply,
//! the "color" of a piece is determined by that position in [Cube::SOLVED](crate::generic::Cube::SOLVED).
//! the "color" of a piece is determined by that position in [`Cube::SOLVED`](crate::generic::Cube::SOLVED).
//!
//! You can use the functions [utils::item_at](crate::generic::utils::item_at) and
//! [utils::position_of_item](crate::generic::utils::position_of_item) to find where
//! You can use the functions [`utils::item_at`](crate::generic::utils::item_at) and
//! [`utils::position_of_item`](crate::generic::utils::position_of_item) to find where
//! pieces are.

mod cube2;
Expand Down Expand Up @@ -51,7 +51,7 @@ use self::space::Direction;
type Vec2 = Vector2<Direction>;
type Vec3 = Vector3<Direction>;

/// An NxNxN cube.
/// An `NxNxN` cube.
///
/// Currently just a marker trait.
pub trait CubeN: generic::Cube {
Expand Down
4 changes: 2 additions & 2 deletions barbarosa/src/cube_n/moves/extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use super::{

/// Fancier moves that only work on [`Orientable`] cubes.
///
/// In regular NxN cubes, you can only do [`AxisMove`]s and [`WideAxisMove`]s. However, with orientable
/// cubes you can use [`ExtendedAxisMove`]s which are basically any move you can imagine on an NxN.
/// In regular `NxN` cubes, you can only do [`AxisMove`]s and [`WideAxisMove`]s. However, with orientable
/// cubes you can use [`ExtendedAxisMove`]s which are basically any move you can imagine on an `NxN`.
///
/// Look at the variants of the enum for specifics.
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
8 changes: 4 additions & 4 deletions barbarosa/src/cube_n/moves/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Moves for NxNxN cubes
//! Moves for `NxNxN` cubes

use std::mem::{self, MaybeUninit};

Expand Down Expand Up @@ -32,9 +32,9 @@ pub use wide::WideAxisMove;
/// It can be either single, double or inverse.
///
/// Variants of axis moves are:
/// - [WideAxisMove] for big cubes (4x4 and up)
/// - [QuarterAxisMove]
/// - [NonRedundantAxisMove]
/// - [`WideAxisMove`] for big cubes (4x4 and up)
/// - [`QuarterAxisMove`]
/// - [`NonRedundantAxisMove`]
#[derive(Debug, PartialEq, Eq, Clone, RandGen)]
pub struct AxisMove {
/// The face that is being rotated
Expand Down
16 changes: 8 additions & 8 deletions barbarosa/src/cube_n/moves/non_redundant.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Moves that reduce redundancies.
//!
//! See [NonRedundantAxisMove] for more info.
//! See [`NonRedundantAxisMove`] for more info.

use std::iter;

Expand All @@ -15,20 +15,20 @@ use crate::{

use super::{Amount, AxisMove};

/// A type of move used to prevent redundancies in [AxisMove]s.
/// A type of move used to prevent redundancies in [`AxisMove`]s.
///
/// This redundancy arises
/// because you can have something like `R R` or `R L R' L` which can clearly be simplified.
/// [NonRedundantAxisMove] implements this by encoding all possible types of move in one axis.
/// [`NonRedundantAxisMove`] implements this by encoding all possible types of move in one axis.
/// This way you can check the axis of the previous move and select only moves from another axis
/// on the next one (see [Self::of_axis] and [Self::given_last_axis] for more info).
/// on the next one (see [`Self::of_axis`] and [`Self::given_last_axis`] for more info).
///
/// # Note
///
/// Technically, this doesn't prevent all redundancies. For example, you could make six sexy moves or
/// two T perms at any point and that's cleary simplifiable. Actually, every sequence of more than 20
/// moves is always going to have some redundancy. However, finding this redundancies basically as
/// hard as solving the cube, so it misses the point. [NonRedundantAxisMove] is just meant to reduce
/// hard as solving the cube, so it misses the point. [`NonRedundantAxisMove`] is just meant to reduce
/// the very obvious and very common redundancies.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum NonRedundantAxisMove {
Expand Down Expand Up @@ -125,12 +125,12 @@ impl NonRedundantAxisMove {
}
}

/// Tries to absorve an [AxisMove] into a [NonRedundantAxisMove].
/// Tries to absorve an [`AxisMove`] into a [`NonRedundantAxisMove`].
///
/// In this context, "absorve" means modifying the original [NonRedundantAxisMove] in such
/// In this context, "absorve" means modifying the original [`NonRedundantAxisMove`] in such
/// a way that the result is the same as doing both moves sequentially.
///
/// This function modifies `self` in-place. It returns an [AbsorveResult] specifying
/// This function modifies `self` in-place. It returns an [`AbsorveResult`] specifying
/// what happened with the input move.
///
/// # Example
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/moves/perms.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Collection of "perms" (algs for permutating pieces) for NxNxN cubes
//! Collection of "perms" (algs for permutating pieces) for `NxNxN` cubes

use once_cell::sync::Lazy;

Expand Down
10 changes: 5 additions & 5 deletions barbarosa/src/cube_n/moves/rotation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Rotations of NxNxN cubes.
//! Rotations of `NxNxN` cubes.
//!
//! This is mainly used because, for example, L and R' are the same rotation and
/// the only difference is the pieces selected in the rotation.
Expand All @@ -14,7 +14,7 @@ use crate::{

use super::{Amount, AxisMove};

/// A rotation around an axis. This is similar to an [AxisMove](super::AxisMove), but it doesn't
/// A rotation around an axis. This is similar to an [`AxisMove`](super::AxisMove), but it doesn't
/// specify the face.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AxisRotation {
Expand All @@ -25,7 +25,7 @@ pub struct AxisRotation {
}

impl AxisRotation {
/// Creates a new [AxisRotation]
/// Creates a new [`AxisRotation`]
pub fn new(axis: Axis, amount: Amount) -> Self {
Self { axis, amount }
}
Expand All @@ -48,12 +48,12 @@ impl AxisRotation {

/// Things that can be rotated.
pub trait Rotatable: Sized {
/// Rotates a piece according to an [AxisRotation]
/// Rotates a piece according to an [`AxisRotation`]
fn rotate(&mut self, rotation: &AxisRotation);

/// Returns a rotated copy of the piece
///
/// See also [Self::rotate]
/// See also [`Self::rotate`]
fn rotated(mut self, rotation: &AxisRotation) -> Self {
self.rotate(rotation);
self
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/moves/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn assert_rotations<T: Rotatable + Clone + Eq + Debug>(
expectations: &[(AxisRotation, T)],
) {
for (rotation, expected_face) in expectations {
let rotated = initial.clone().rotated(&rotation);
let rotated = initial.clone().rotated(rotation);
assert_eq!(&rotated, expected_face, "Rotation: {:?}", rotation);
}
}
Expand Down
6 changes: 3 additions & 3 deletions barbarosa/src/cube_n/moves/wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<const N: u32> generic::Move for WideAxisMove<N> {
impl<const N: u32> WideAxisMove<N> {
/// Creates a new [`WideAxisMove<N>`].
///
/// Returns [WideMoveCreationError] if the depth is greater than `N`.
/// Returns [`WideMoveCreationError`] if the depth is greater than `N`.
pub fn new(face: Face, amount: Amount, depth: u32) -> Result<Self, WideMoveCreationError> {
if depth > N {
return Err(WideMoveCreationError::ExcededDepth(depth, N));
Expand Down Expand Up @@ -71,7 +71,7 @@ impl<const N: u32> WideAxisMove<N> {

/// Tries to set the depth of the move in-place.
///
/// Fails and returns [WideMoveCreationError] if the depth is greater than `N`.
/// Fails and returns [`WideMoveCreationError`] if the depth is greater than `N`.
pub fn set_depth(&mut self, new_depth: u32) -> Result<(), WideMoveCreationError> {
if new_depth > N {
return Err(WideMoveCreationError::ExcededDepth(new_depth, N));
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<const N: u32> Distribution<WideAxisMove<N>> for rand::distributions::Standa
}

impl Alg<AxisMove> {
/// Widens an axis move into a [WideAxisMove].
/// Widens an axis move into a [`WideAxisMove`].
///
/// Fails if the depth is greater than `N`.
pub fn widen<const N: u32>(
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/pieces/center/corner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Center corner piece. See [CenterCorner] for more info.
//! Center corner piece. See [`CenterCorner`] for more info.

use cartesian_array_product::cartesian_array_map;
use nalgebra::vector;
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/pieces/center/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The different types of centers in NxNxN cubes.
//! The different types of centers in `NxNxN` cubes.

pub mod corner;
pub mod edge;
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/pieces/center/wing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::edge::CenterEdge;

/// The center-wing piece. It's the center version of the [Wing](crate::cube_n::Wing) piece.
///
/// [CenterEdge]s have a tangent depth and [CenterCorner](super::corner::CenterCorner)s have a normal depth. A [CenterWing] need both to
/// [`CenterEdge`]s have a tangent depth and [`CenterCorner`](super::corner::CenterCorner)s have a normal depth. A [`CenterWing`] need both to
/// be identified.
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct CenterWing {
Expand Down
8 changes: 4 additions & 4 deletions barbarosa/src/cube_n/pieces/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ impl PieceSetDescriptor<12> for Edge {
///
/// Edges are set up this way so that an X2 rotation increases the index by 6.
/// That is, `SOLVED[n]` and `SOLVED[n + 6]` differ by an X2 rotation. This is
/// useful for indexing into the HalfEdges permutation table with the second half
/// useful for indexing into the `HalfEdges` permutation table with the second half
/// of the edges.
///
/// See [crate::cube_n::cube3::mus] for more information.
/// See [`crate::cube_n::cube3::mus`] for more information.
const SOLVED: [Edge; 12] = {
const fn from_tuple((axis, pos): <Edge as Piece>::Position) -> Edge {
Edge::oriented(axis, pos)
Expand Down Expand Up @@ -169,15 +169,15 @@ impl Edge {

/// Returns the edge with the opposite orientation.
///
/// See also [Edge::flip()] for mutating instead of owning.
/// See also [`Edge::flip`()] for mutating instead of owning.
pub const fn flipped(mut self) -> Self {
self.oriented = !self.oriented;
self
}

/// Flips the orientation of the edge.
///
/// See also [Edge::flipped()] for owning instead of mutating.
/// See also [`Edge::flipped`()] for owning instead of mutating.
pub fn flip(&mut self) {
self.oriented = !self.oriented;
}
Expand Down
2 changes: 1 addition & 1 deletion barbarosa/src/cube_n/pieces/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Pieces of an NxNxN cube.
//! Pieces of an `NxNxN` cube.

pub mod center;
pub mod corner;
Expand Down
Loading

0 comments on commit dcd4c6b

Please sign in to comment.