Fix errors and inconcistency with this requirement in the part of the minimal viable…
- User
Fix errors and inconcistency with this requirement in the part of the minimal viable solution of the problems, written in rust code, using only std and libraries that is explicitly used in code below, pointing in which files which update needed and which new files need to create with which code. Task: define in …/project/src/datacode.rs a Global Struct and a Generic, that can be read and updated by any function or macro in …/project/src/main.rs or …/project/src/subproject/src/lib.rs, intended for filling data from a bunch of files. Above data strutures are initializing with the same set of rows, taken from files, which rows consisting of 3 cells type of &str. Although I explicitly mentioning the type of the cells in this task as &str, this is just for example, so design each data structs so it can deal with any type of data not limiting to string cells or example ones. Again, just for example, use hashmap (use 1st &str as a key, two rest as values), hashset (all three cells goes into hashset as \t tab-separated in one string), vec (use 1st &str as a key, rest as values), and another entity BinaryHeap in similar fashion. There are errors
/* error: src/datacode.rs:44: the trait bound
T: Ordis not satisfied error: src/datacode.rs:44: the traitOrdis not implemented forTnote: src/datacode.rs:44: required for(T, &str, T)to implementOrdnote: src/datacode.rs:21: required by a bound in this note: src/datacode.rs:20: required by a bound indatacode::BinaryHeap::<T>::newnote: src/datacode.rs:20: required by this bound inBinaryHeap::<T>::newhelp: src/datacode.rs:37: consider further restricting this bound error: src/datacode.rs:73: mismatched types error: src/datacode.rs:73: expected type parameterT, found structStringerror: src/datacode.rs:73: arguments to this enum variant are incorrect note: src/datacode.rs:73: expected structMyGlobalStruct<'_, T>found structMyGlobalStruct<'_, String>help: src/datacode.rs:73: this argument influences the type ofOkhelp: src/datacode.rs:73: the type constructed containsMyGlobalStruct<'_, String>due to the type of the argument passed note: src/datacode.rs:73: tuple variant defined here error: src/datacode.rs:35: this type parameter*/
in the …/project/src/datacode.rs part: use std::collections::{BTreeMap, HashMap, HashSet}; use std::cmp::Reverse; use std::fs::File; use std::io::{self, BufRead, BufReader};
#[derive(Debug)] pub struct MyGlobalStruct<'a, T> { hashmap: HashMap<&'a str, (T, T, T)>, hashset: HashSet, vec: Vec<(&'a str, (T, T, T))>, binary_heap: BinaryHeap<(T, &'a str, T)>, // add other fields as needed }
#[derive(Debug)] pub struct BinaryHeap { heap: Vec, }
impl<T: Ord> BinaryHeap { pub fn new() -> Self { BinaryHeap { heap: Vec::new() } }
- Assistant