Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
Cargo.lock
.idea
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ repository = "https://github.com/b-inary/postflop-solver"
license = "AGPL-3.0-or-later"

[dependencies]
bincode = { version = "2.0.0-rc.3", optional = true }
bincode = { version = "2.0.1", optional = true }
once_cell = "1.18.0"
rayon = { version = "1.8.0", optional = true }
regex = "1.9.6"
rayon = { version = "1.11.0", optional = true }
regex = "1.12.2"
zstd = { version = "0.12.4", optional = true, default-features = false }

[features]
Expand Down
9 changes: 6 additions & 3 deletions src/action_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,12 @@ impl ActionTree {
let mut node = &*self.root.lock() as *const ActionTreeNode;
for action in &self.history {
while (*node).is_chance() {
node = &*(*node).children[0].lock();
let node_ref = &*node;
node = &*node_ref.children[0].lock();
}
let index = (*node).actions.iter().position(|x| x == action).unwrap();
node = &*(*node).children[index].lock();
let node_ref = &*node;
node = &*node_ref.children[index].lock();
}
&*node
}
Expand All @@ -405,7 +407,8 @@ impl ActionTree {
unsafe {
let mut node = self.current_node() as *const ActionTreeNode;
while (*node).is_chance() {
node = &*(*node).children[0].lock();
let node_ref = &*node;
node = &*node_ref.children[0].lock();
}
&*node
}
Expand Down
4 changes: 2 additions & 2 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum DataType {
}

/// A trait for data that can be saved into a file.
pub trait FileData: Decode + Encode {
pub trait FileData: Decode<()> + Encode {
#[doc(hidden)]
fn data_type() -> DataType;
#[doc(hidden)]
Expand Down Expand Up @@ -139,7 +139,7 @@ pub fn save_data_to_file<T: FileData, P: AsRef<Path>>(
save_data_into_std_write(data, memo, &mut writer, compression_level)
}

fn decode_from_std_read<D: Decode, R: Read>(reader: &mut R, err_msg: &str) -> Result<D, String> {
fn decode_from_std_read< D: Decode<()>, R: Read>(reader: &mut R, err_msg: &str) -> Result<D, String> {
bincode::decode_from_std_read(reader, bincode::config::standard())
.map_err(|e| format!("{}: {}", err_msg, e))
}
Expand Down
6 changes: 3 additions & 3 deletions src/game/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ impl Encode for PostFlopGame {
}
}

impl Decode for PostFlopGame {
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
impl Decode<()> for PostFlopGame {
fn decode<D: Decoder<Context = ()>>(decoder: &mut D) -> Result<Self, DecodeError> {
// version check
let version = String::decode(decoder)?;
if version != VERSION_STR {
Expand Down Expand Up @@ -292,7 +292,7 @@ impl Encode for PostFlopNode {
}
}

impl Decode for PostFlopNode {
impl Decode<()> for PostFlopNode {
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
// node instance
let mut node = Self {
Expand Down
8 changes: 4 additions & 4 deletions src/mutex_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ impl<T: Encode> Encode for MutexLike<T> {
}

#[cfg(feature = "bincode")]
impl<T: Decode> Decode for MutexLike<T> {
impl<Context, T: Decode<Context>> Decode<Context> for MutexLike<T> where {
#[inline]
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
fn decode<D: Decoder<Context = Context>>(decoder: &mut D) -> Result<Self, DecodeError> {
Ok(Self::new(T::decode(decoder)?))
}
}

#[cfg(feature = "bincode")]
impl<'de, T: BorrowDecode<'de>> BorrowDecode<'de> for MutexLike<T> {
impl<'de, Context, T: BorrowDecode<'de, Context>> BorrowDecode<'de, Context> for MutexLike<T> {
#[inline]
fn borrow_decode<D: BorrowDecoder<'de>>(decoder: &mut D) -> Result<Self, DecodeError> {
fn borrow_decode<D: BorrowDecoder<'de, Context = Context>>(decoder: &mut D) -> Result<Self, DecodeError> {
Ok(Self::new(T::borrow_decode(decoder)?))
}
}