This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::str; | |
fn main() { | |
// -- FROM: vec of chars -- | |
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}']; | |
// to String | |
let string1: String = src1.iter().collect::<String>(); | |
// to str | |
let str1: &str = &src1.iter().collect::<String>(); | |
// to vec of byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![windows_subsystem = "windows"] | |
use gtk::prelude::*; | |
use std::{thread, time::Duration}; | |
fn main() { | |
println!("Hello, world!"); | |
if gtk::init().is_err() { | |
eprintln!("failed to initialize"); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Flux | |
using Plots | |
x = [0f0 0 1 1; 0 1 0 1] | |
y = [0f0 1 1 0] | |
xornn_model = Chain( | |
Dense(2, 2, σ), | |
Dense(2, 1, σ) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use pyo3::{ | |
prelude::pyfunction, prelude::pymodule, types::PyModule, wrap_pyfunction, PyResult, Python, | |
}; | |
#[pyfunction] | |
fn sum_numbers(a: usize, b: usize) -> PyResult<usize> { | |
Ok(a + b) | |
} | |
#[pymodule] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use cursive::{ | |
self, traits::Boxable, traits::Nameable, views::Button, views::Dialog, views::DummyView, | |
views::EditView, views::LinearLayout, views::SelectView, Cursive, | |
}; | |
fn main() { | |
let mut siv = cursive::default(); | |
let select = SelectView::<String>::new() | |
.on_submit(on_submit) | |
.with_name("select") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "cursive_test_windows" | |
version = "0.1.0" | |
authors = ["unknown <[email protected]>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies.cursive] | |
version = "0.15.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{cell::RefCell, rc::Rc}; | |
type SingLink = Option<Rc<RefCell<Node>>>; | |
#[derive(Clone)] | |
struct Node { | |
value: String, | |
next: SingLink, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{fmt::Display, io::BufReader, io::Read, io::Write, str}; | |
struct MyBuffer { | |
buf: Vec<u8>, | |
off: usize, | |
} | |
impl MyBuffer { | |
fn new(data: &[u8]) -> MyBuffer { | |
MyBuffer { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{sync::mpsc, sync::Arc, sync::Mutex, thread}; | |
type Closure = Box<dyn FnOnce() + Send + 'static>; | |
const ERR_LOCK: &str = "cant acquire resource"; | |
fn main() { | |
let (tx, rx) = mpsc::channel::<Closure>(); | |
let rxtf = Arc::new(Mutex::new(rx)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{sync::mpsc, thread}; | |
type Closure = Box<dyn FnOnce() + Send + 'static>; | |
fn main() { | |
let (tx, rx) = mpsc::channel::<Closure>(); | |
let handle = thread::spawn(move ||{ | |
while let Ok(data) = rx.recv(){ | |
data(); | |
} |