Skip to content

Commit

Permalink
Merge pull request fedimint#5795 from tvolk131/core_splitting
Browse files Browse the repository at this point in the history
chore: remove IntoDynNever
  • Loading branch information
tvolk131 authored Aug 16, 2024
2 parents 889ea4f + 17e5a65 commit 9d6fb7b
Showing 1 changed file with 0 additions and 60 deletions.
60 changes: 0 additions & 60 deletions fedimint-core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::fmt::{Debug, Display, Formatter};
use std::io::Read;
use std::str::FromStr;
use std::sync::Arc;
use std::{cmp, marker};

use anyhow::anyhow;
use bitcoin_hashes::{sha256, Hash};
Expand Down Expand Up @@ -228,10 +227,6 @@ impl Encodable for DynUnknown {
}

/// A type that has a `Dyn*`, type erased version of itself
///
/// Use [`IntoDynNever`] in places where a given type will never
/// actually be created, but something is needed to appease the
/// type system.
pub trait IntoDynInstance {
/// The type erased version of the type implementing this trait
type DynType: 'static;
Expand All @@ -240,61 +235,6 @@ pub trait IntoDynInstance {
fn into_dyn(self, instance_id: ModuleInstanceId) -> Self::DynType;
}

enum Never {}

/// Type that can be used as type-system placeholder for [`IntoDynInstance`]
pub struct IntoDynNever<T> {
_phantom: marker::PhantomData<T>,
// you can't make that
_never: Never,
}

impl<T> cmp::PartialEq for IntoDynNever<T> {
fn eq(&self, _: &Self) -> bool {
unreachable!()
}
}

impl<T> cmp::Eq for IntoDynNever<T> {}

impl<T> fmt::Debug for IntoDynNever<T> {
fn fmt(&self, _: &mut Formatter<'_>) -> fmt::Result {
unreachable!()
}
}

impl<T> Clone for IntoDynNever<T> {
fn clone(&self) -> Self {
unreachable!()
}
}

impl<T> Encodable for IntoDynNever<T> {
fn consensus_encode<W: std::io::Write>(&self, _: &mut W) -> Result<usize, std::io::Error> {
unreachable!()
}
}

impl<T> Decodable for IntoDynNever<T> {
fn consensus_decode<R: std::io::Read>(
_: &mut R,
_: &ModuleDecoderRegistry,
) -> Result<Self, DecodeError> {
unreachable!()
}
}

impl<T> IntoDynInstance for IntoDynNever<T>
where
T: 'static,
{
type DynType = T;

fn into_dyn(self, _instance_id: ModuleInstanceId) -> Self::DynType {
unreachable!()
}
}

type DecodeFn = Box<
dyn for<'a> Fn(
Box<dyn Read + 'a>,
Expand Down

0 comments on commit 9d6fb7b

Please sign in to comment.