feat(cheatsheet): remove list of position errors

This commit is contained in:
doryan 2024-08-09 20:51:28 +04:00
parent 631db86420
commit 7d2049b59d
4 changed files with 35 additions and 47 deletions

View File

@ -5,21 +5,6 @@ use crate::{
model::models::*,
};
/// **Синдромы**
///
/// ошибочная позиция 1 false true true.
///
/// ошибочная позиция 2 false false true.
///
/// ошибочная позиция 3 true false true.
///
/// ошибочная позиция 4 false true false.
///
/// ошибочная позиция 5 true true false.
///
/// ошибочная позиция 6 true false false.
///
/// ошибочная позиция 7 false false false.
pub fn hamming(raw_input: String, mode: HammingMode) -> Result<String, String> {
let length_of_code: usize = mode.clone() as usize;

View File

@ -1,9 +1,10 @@
pub trait Product<B, T> {
fn builder() -> B;
fn get(self) -> T;
fn get(&self) -> &T;
}
#[allow(dead_code)]
pub trait Builder<T, I, P> {
fn build(&self, build_arg: P) -> T;

View File

@ -2,14 +2,19 @@ pub mod builder_traits;
pub mod models;
use crate::gtk::glib;
use glib::Object;
glib::wrapper! {
pub struct ResultValue(ObjectSubclass<models::ResultValue>);
pub struct Frequency(ObjectSubclass<models::Frequency>);
}
impl ResultValue {
pub fn new(val: f64) -> Self {
Object::builder().property("value", val).build()
impl Frequency {
pub fn new(frequency: f64) -> Self {
Object::builder().property("frequency", frequency).build()
}
pub fn default() -> Self {
Object::new()
}
}

View File

@ -2,10 +2,11 @@ use std::cell::Cell;
use crate::gtk;
use glib::Properties;
use gtk::glib;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{
glib::{self, Properties},
prelude::*,
subclass::prelude::*,
};
#[repr(usize)]
#[derive(Clone)]
@ -14,33 +15,29 @@ pub enum HammingMode {
Decrypt = 7,
}
pub struct EventHandler<F, C> {
pub(crate) component: C,
pub(crate) callback: F,
}
#[derive(Default, Copy, Clone)]
pub struct SignalReduce(pub f64, pub f64, pub f64, pub f64, pub f64, pub f64);
impl SignalReduce {
pub fn new() -> Self {
Self(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
}
#[allow(dead_code)]
#[derive(Default, Copy, Clone, Debug)]
pub struct SignalReduce {
pub length: f64,
pub wire_resistance: f64,
pub wire_capacity: f64,
pub source_voltage: f64,
pub source_resistance: f64,
pub frequency: f64,
}
#[derive(Properties, Default)]
#[properties(wrapper_type = super::ResultValue)]
pub struct ResultValue {
#[properties(wrapper_type = super::Frequency)]
pub struct Frequency {
#[property(get, set)]
value: Cell<f64>,
}
// The central trait for subclassing a GObject
#[glib::object_subclass]
impl ObjectSubclass for ResultValue {
const NAME: &'static str = "MyGtkAppCustomButton";
type Type = super::ResultValue;
frequency: Cell<f64>,
}
#[glib::derived_properties]
impl ObjectImpl for ResultValue {}
impl ObjectImpl for Frequency {}
#[glib::object_subclass]
impl ObjectSubclass for Frequency {
const NAME: &'static str = "FrequencyValue";
type Type = super::Frequency;
}