blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
140
path
stringlengths
5
183
src_encoding
stringclasses
6 values
length_bytes
int64
12
5.32M
score
float64
2.52
4.94
int_score
int64
3
5
detected_licenses
listlengths
0
47
license_type
stringclasses
2 values
text
stringlengths
12
5.32M
download_success
bool
1 class
18aa2990f197a097805bd02b33c2969b26a009b7
Rust
llenotre/maestro_tester
/src/test_machine.rs
UTF-8
3,628
3.328125
3
[]
no_license
use std::net::UdpSocket; use std::thread; use std::time; use serde::Deserialize; use crate::gpio::GPIO; /// The number of magic packets to send (to ensure it is received). const WOL_COUNT: usize = 3; /// The delay between each magic packet in milliseconds. const WOL_DELAY: u64 = 100; /// Structure representing a te...
true
f61a8c13d3523a59fb9ca18e8eb8d8b42fcc2ec4
Rust
wwkeyboard/flickrator
/src/photosets_get.rs
UTF-8
3,192
3
3
[ "MIT" ]
permissive
use crate::Config; use anyhow::Result; use serde::Deserialize; #[derive(Deserialize, Debug)] pub struct Response { pub photoset: Photoset, } #[derive(Deserialize, Debug)] pub struct Photoset { pub id: String, pub primary: String, pub owner: String, pub ownername: String, pub photo: Vec<Photo>,...
true
af7fc08cd1a1c5c154a825af72c4a69d5857ff6b
Rust
mgill25/Rust-Smart-Pointers
/reference_counting_2.rs
UTF-8
1,918
3.875
4
[]
no_license
// A much cleaner example of reference counting's use cases is presented here. // // Scenario: We have *Gadgets*, and many Gadgets can have a single *Owner* (I own a pencil, a // screwdriver, a hammer etc). // Because of such a requirement, we want multiple Gadgets to point to the same Owner. This isn't // easily poss...
true
ceecfb3455185e1f6e93914bc8b8d2e241bd84f9
Rust
gitter-badger/stellar-sdk
/client/src/client/sync/iter.rs
UTF-8
3,408
3.15625
3
[ "MIT" ]
permissive
use endpoint::{Cursor, IntoRequest, Records}; use serde::de::DeserializeOwned; use super::Client; use error::Result; /// An iterator for records. Provides the ability to use the iterator /// in rust against records that are returned from the api. /// /// # Examples /// /// ``` /// use stellar_client::{ /// endpoin...
true
0ec568c200e762f80184d46418ad7cfa864620fb
Rust
QuestofIranon/grm
/src/commands.rs
UTF-8
1,240
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
pub mod get; pub mod list; pub mod root; use structopt::StructOpt; use anyhow::{anyhow, Context, Result}; use dirs::home_dir; use enum_dispatch::enum_dispatch; use git2::Config; use std::{option::NoneError, path::PathBuf}; #[enum_dispatch] #[derive(StructOpt, Debug)] #[structopt(name = "grm", about = "Git remote rep...
true
09ad9ff3979431c249484b62b4a7c045a30fac55
Rust
gwilymk/arduino-joystick
/joystick-daemon/src/joystick/axis.rs
UTF-8
538
2.890625
3
[ "MIT" ]
permissive
use std::slice; #[derive(Debug)] pub enum Axis { X, Y, RX, RY, } impl Axis { pub(super) fn to_evdev_axis(&self) -> input_linux::AbsoluteAxis { use Axis::*; match &self { X => input_linux::AbsoluteAxis::X, Y => input_linux::AbsoluteAxis::Y, RX =>...
true
df4dde9ffc9ee7eaf4cbcb58a95d808d635ff315
Rust
Alpvax/rust-aoc-2015
/src/bin/day9.rs
UTF-8
1,615
3.0625
3
[]
no_license
use rust_2015::read_lines; use itertools::Itertools; use std::collections::HashMap; use fancy_regex::Regex; fn main() { let pattern = Regex::new(r"(\w+) to (\w+) = (\d+)").unwrap(); let mut routemap/*: HashMap<String, HashMap<String, u32>>*/ = HashMap::new(); for line in //["London to Dublin = 464", "L...
true
21de49f681a06efdeb19215fcc4ae3e4c7f0973c
Rust
RangerStation/alexandrie-run
/.cargo/registry/src/github.com-1ecc6299db9ec823/hkdf-0.8.0/src/hkdf.rs
UTF-8
4,643
3.203125
3
[ "Apache-2.0", "MIT" ]
permissive
//! An implementation of HKDF, the [HMAC-based Extract-and-Expand Key Derivation Function][1]. //! //! # Usage //! //! ```rust //! # extern crate hex; //! # extern crate hkdf; //! # extern crate sha2; //! //! # use sha2::Sha256; //! # use hkdf::Hkdf; //! //! # fn main() { //! let ikm = hex::decode("0b0b0b0b0b0b0b0b0b0b...
true
be066b53ba6b933989663582d895c56eb6800b1d
Rust
Sollimann/rust_grpc
/src/server.rs
UTF-8
2,990
3.03125
3
[]
no_license
//We would use tokio::sync::mpsc for communicating between futures use tokio::sync::mpsc; // gRPC tools use tonic::{transport::Server, Request, Response, Status}; // our messages and services use hello::say_server::{Say, SayServer}; use hello::{SayResponse, SayRequest}; mod hello; // defining a struct for our servic...
true
000725b3823348e96c0e847cc7d09b3bbbfca9a5
Rust
AdelaideAuto-IDLab/bTracked
/base_station/src/source/serial.rs
UTF-8
6,078
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::{path::PathBuf, thread, time::Duration}; use crossbeam_channel as channel; use serialport::{self, SerialPort}; use {util, BeaconPacket}; pub fn serial_source( path: PathBuf, version: usize, settings: serialport::SerialPortSettings, mut output: channel::Sender<BeaconPacket> ) { let mut r...
true
412d1a8bf634ae511a16b407d6a17b1080012f9e
Rust
wathiede/pbrt
/src/lib.rs
UTF-8
5,922
2.921875
3
[ "Apache-2.0" ]
permissive
// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
true
98a90367f0fc7505b1bca1531ca94934f56f44f0
Rust
AtsukiTak/window.art
/server/artell-infra/src/fs/image.rs
UTF-8
709
2.828125
3
[]
no_license
use artell_domain::image::{Image, ImageRepository}; use std::path::PathBuf; pub struct FsImageRepository { path: PathBuf, } impl FsImageRepository { pub fn new(path: PathBuf) -> Self { assert!(path.is_dir()); FsImageRepository { path } } } #[async_trait] impl ImageRepository for FsImageR...
true
27d3a4c6ad98ccbba5b9ed46303638850548293d
Rust
kildevaeld/tasks-rs
/service/src/unpack.rs
UTF-8
1,225
2.546875
3
[]
no_license
use super::Extract; use crate::{Rejection, Service}; use core::future::Future; use core::pin::Pin; use core::task::{Context, Poll}; use futures_core::ready; use pin_project::pin_project; #[derive(Clone)] pub struct Unpack<T>(pub(crate) T); impl<T, R> Service<R> for Unpack<T> where T: Service<R>, T::Output: Ex...
true
24d4ddb7ef16f00a11a2c3881365e4a7dcdb1a05
Rust
mripard/marcel
/src/trace.rs
UTF-8
5,167
2.78125
3
[]
no_license
use std::fmt; use std::fs::File; use std::io; use std::io::BufRead; use std::str; use nom::is_hex_digit; use nom::is_space; use error::Result; use error::MarcelError; pub struct RegisterWrite { pub register: u64, pub value: u64, timestamp: String, } impl fmt::Debug for RegisterWrite { fn fmt(&self...
true
c1d4240883119fa8a44895d03b29c36f50ce3d7c
Rust
rick68/rust-trace
/libcore/cell/enum_BorrowState/BorrowState.rs
UTF-8
518
2.75
3
[ "MIT" ]
permissive
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::cell::BorrowState::{self, Reading, Writing, Unused}; // pub enum BorrowState { // /// The cell is currently being read, there is at least one active `borrow`. // Reading, // /// The cell is currently being written ...
true
0adbb2ed45596c6bc4cae713c4e3b97ff5963b2d
Rust
nuclearfurnace/rs-storm-parser
/src/storm_parser/tracker.rs
UTF-8
9,010
2.78125
3
[]
no_license
use std::io; use std::borrow::BorrowMut; use std::collections::HashMap; use mpq::Archive; use num_traits::FromPrimitive; use storm_parser::replay::StormReplay; use storm_parser::binary_reader::BinaryReader; use storm_parser::primitives::*; #[derive(Serialize, Clone, Debug, Default)] pub struct TrackerEventStructure ...
true
f2416a934e3db055fa4078c780305885c32f5556
Rust
tnctinfossl/global-rust
/vision/src/updater.rs
UTF-8
2,627
2.703125
3
[]
no_license
use super::messages_robocup_ssl_detection::*; use super::messages_robocup_ssl_wrapper::*; use glm::{distance, Vec2}; use model; use std::time::{Duration, Instant}; pub struct Updater { mergin: f32, //同一オブジェクトとみなす距離[mm] time_limit: Duration, } impl Updater { pub fn new(mergin: f32, time_limit: Duration) -> ...
true
a2ce5830c92ffa3a8953bd7239249f53c71e911f
Rust
fredyw/leetcode
/src/main/rust/src/bin/problem2712.rs
UTF-8
1,332
3.53125
4
[ "MIT" ]
permissive
// https://leetcode.com/problems/minimum-cost-to-make-all-characters-equal/ pub fn minimum_cost(s: String) -> i64 { fn cost(chars: &Vec<char>, c: char) -> i64 { let mut total_count: i64 = 0; let mid = chars.len() / 2; let mut count = 0; for i in (0..mid).rev() { if (count...
true
29dbc372068fa97a9db290e78338b5abd053b072
Rust
gvvynplaine/bottom
/src/app/data_farmer.rs
UTF-8
11,986
2.796875
3
[ "MIT" ]
permissive
use lazy_static::lazy_static; /// In charge of cleaning, processing, and managing data. I couldn't think of /// a better name for the file. Since I called data collection "harvesting", /// then this is the farmer I guess. /// /// Essentially the main goal is to shift the initial calculation and distribution /// of jo...
true
0257bb476a9f92d3109a5962539ebf1eea4a1fd7
Rust
fhaynes/palladium
/src/dictionary_parsers.rs
UTF-8
1,899
3.75
4
[ "MIT" ]
permissive
//! This contains functions related to parsing dictionaries. In Palladium, a dictionary //! looks like this: //! ```python //! x = {key: value} //! ``` //! //! Dictionaries may use any type as a key and value //! use nom::*; use nom::types::CompleteStr; use tokens::Token; use expression_parsers::expression; use fac...
true
74ee1cecbccc1c1f56b38a0325398af0e3e4ccfe
Rust
cevans01/hanabi
/src/rules.rs
UTF-8
1,144
3.03125
3
[]
no_license
use std::collections::VecDeque; use crate::card::{generate_deck, Card, Number}; use crate::errors::HanabiError; pub const MAX_HINTS: u8 = 8; pub const NUM_BOMBS: u8 = 3; pub const MAX_PLAYERS: u8 = 5; pub const MIN_PLAYERS: u8 = 2; pub enum GameResultState { Finished(usize), InProgress, } pub fn cards_to_d...
true
3547c5cdc101ddaa377f14cbd8b9ffda9b041a37
Rust
jz4o/codingames
/rust/practice/classic_puzzle/easy/text-formatting.rs
UTF-8
1,616
3.34375
3
[]
no_license
use std::io; use regex::Regex; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ fn main() { let mut input_line = String::new(); io::stdin().read_...
true
7e9097328f997edc0b43e0c483797ae335e8759b
Rust
TrionProg/pz5_collada
/src/error.rs
UTF-8
3,187
3.046875
3
[]
no_license
use std; use collada; /* struct Error{ route:Route, kind:ErrorKind, } impl Error{ pub fn new(stage:&Stage, kind:ErrorKind) -> Error{ Error{ route:Route::from(stage), kind:kind, } } } macro_rules! throw{ ($kind:expr) => ( return Err(Error::new(curren...
true
c92437b92754e927cf741d265bb52be81554b4f7
Rust
SuperiorJT/twilight
/model/src/channel/message/reaction.rs
UTF-8
1,244
2.984375
3
[ "ISC" ]
permissive
use crate::channel::ReactionType; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct MessageReaction { pub count: u64, pub emoji: ReactionType, pub me: bool, } #[cfg(test)] mod tests { use super::{MessageReaction, ReactionType}; use...
true
7f270a035c9740267b557f8e10b938ab3bb5ad0d
Rust
EFanZh/LeetCode
/src/problem_0680_valid_palindrome_ii/mod.rs
UTF-8
595
2.984375
3
[]
no_license
pub mod iterative; pub trait Solution { fn valid_palindrome(s: String) -> bool; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ("aba", true), ("abca", true), ("abc", false), ( "aguokepa...
true
ef826f2ceac49a22d3001ae722a19c4a14e0dfb2
Rust
satyamakgec/fe
/parser/src/tokenizer/tokenize.rs
UTF-8
14,717
2.875
3
[ "Apache-2.0" ]
permissive
use regex::Regex; use crate::node::Span; use crate::string_utils::{ lines_with_endings, lstrip_slice, rstrip_slice, }; use crate::tokenizer::regex::{ compile_anchored, get_pseudotoken_pattern, get_single_quote_set, get_triple_quote_set, DOUBLE, DOUBLE3, SINGLE, SINGLE3, }; u...
true
7c688d9b6f4dc782b3ebc175f8c444033ec4e998
Rust
togglebyte/tinystore
/src/possible.rs
UTF-8
675
2.65625
3
[ "MIT" ]
permissive
use std::sync::{Arc, RwLock}; use tinyroute::{Agent, ToAddress, Message}; // * Be notified of a change, but not what changed // * Have a reference, not to mirror the data (that would be silly) #[derive(Debug, Copy, Clone)] pub enum Op { Updated, Removed, // Created, } struct StoreOne<T, A: ToAddress> { ...
true
1b30e16a6abee4b105a169dbfa58e622dcdda60b
Rust
marco-c/gecko-dev-wordified
/third_party/rust/tokio-stream/src/wrappers/mpsc_bounded.rs
UTF-8
1,871
2.765625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate : : Stream ; use std : : pin : : Pin ; use std : : task : : { Context Poll } ; use tokio : : sync : : mpsc : : Receiver ; / / / A wrapper around [ tokio : : sync : : mpsc : : Receiver ] that implements [ Stream ] . / / / / / / [ tokio : : sync : : mpsc : : Receiver ] : struct tokio : : sync : : mpsc : : Recei...
true
eeba442da71874175961936d6f2c9ec34e35c75a
Rust
ia7ck/monkey-compiler-rs
/src/vm.rs
UTF-8
40,797
2.875
3
[ "MIT" ]
permissive
use crate::code::{read_uint16, read_uint8, Instructions, Opcode, DEFINITIONS}; use crate::compiler::Bytecode; use crate::frame::Frame; use crate::object; use crate::object::Object; use anyhow::{bail, ensure, Result}; use std::collections::HashMap; use std::ops::Deref; use std::rc::Rc; const STACK_SIZE: usize = 2048; c...
true
7d105296bf19701b59407da759039c3fcbcf2617
Rust
slog-rs/extlog
/src/lib.rs
UTF-8
8,962
3.578125
4
[ "Apache-2.0" ]
permissive
//! External logging and statistics tracking API for [`slog`]. //! //! This crate adds support for two features to the slog ecosystem. //! //! # Generating "external" logs //! External logs are logs that form an API and so must not be modified or removed //! without agreeing as a spec change. New logs can always safel...
true
ba98379942c68c26680b46861029b20546faf424
Rust
mattvilim/rust-ioc
/ioc/src/container/impls.rs
UTF-8
2,986
3.5625
4
[]
no_license
//! Root dependency implementations //! //! Root dependencies include: //! //! - `()` the only _true_ root dependency that can be used for types //! that can be materialised from nothing. //! - `Rc<T>` a shared instance of `T`. //! - `RefCell<T>` a unique instance of `T`. //! //! These can be combined in various way...
true
bda6299d714dd81c197ab2f0fda61d7f059647f7
Rust
catsanddo/rustblocks
/src/main.rs
UTF-8
1,188
2.515625
3
[ "MIT" ]
permissive
extern crate toml; use std::thread::sleep; use std::time::{Duration, Instant}; use std::process::Command; use std::env; use toml::Value; use rustblocks::block; fn main() { let mut home = env::var("HOME").unwrap(); home.push_str("/.rustblocks.toml"); let config = std::fs::read_to_string(&home).expect("Coul...
true
61a27e10cb68209b712e2b7931b05d96457ec93b
Rust
ipfs-rust/libpacket
/derive/tests/run-pass/payload_optional.rs
UTF-8
437
2.9375
3
[ "MIT", "Apache-2.0" ]
permissive
use libpacket_core::Packet; use libpacket_derive::Packet; #[derive(Debug, Packet)] pub struct PayloadOptional { #[length = "2"] header: Vec<u8>, remaining: Vec<u8>, } fn main() { let packet = [0x9d, 0x7f, 0x3e, 0x7d]; let p = PayloadOptionalPacket::new(&packet[..]).unwrap(); assert_eq!(p.paylo...
true
2842a9df7171d64cc4dccf2be92686e2256c3926
Rust
lukasschlueter/ureq
/src/header.rs
UTF-8
6,110
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::error::{Error, ErrorKind}; use std::fmt; use std::str::FromStr; #[derive(Clone, PartialEq)] /// Wrapper type for a header field. /// https://tools.ietf.org/html/rfc7230#section-3.2 pub struct Header { // Line contains the unmodified bytes of single header field. // It does not contain the final CRLF...
true
2a20a62a6caa50aaff2b6fbd567d8648da96d0a3
Rust
alphazhan/multiplayer_bomber_rust
/src/gamestate.rs
UTF-8
12,395
2.65625
3
[ "MIT" ]
permissive
use rand::{self, Rng}; use crate::utils; use gdnative::api::*; use gdnative::prelude::*; /// Default game server port. Can be any number between 1024 and 49151. /// Not on the list of registered or common ports as of November 2020: /// https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers const DEFAULT_PORT:...
true
7e9668ff6e3f4affb47aab4d9cbef3c3d381d89f
Rust
5l1v3r1/takeover-2
/src/migrator/stage1/efi_files.rs
UTF-8
6,215
2.515625
3
[]
no_license
use crate::common::{call, dir_exists, path_append, Error, ErrorKind, Result, ToError}; use crate::stage1::utils::whereis; use lazy_static::lazy_static; use log::{debug, trace, warn}; use regex::Regex; use std::collections::HashSet; use std::fs::{copy, create_dir_all}; use std::path::{Path, PathBuf}; pub(crate) struct ...
true
fe900d1675362b18d82430a67df92ab2654e30e8
Rust
rust-lang/chalk
/tests/test/functions.rs
UTF-8
8,217
3.265625
3
[ "Apache-2.0", "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "NCSA", "MIT", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Unlicense" ]
permissive
use super::*; #[test] fn functions_are_sized() { test! { program { #[lang(sized)] trait Sized { } } goal { fn(()): Sized } yields { expect![["Unique"]] } goal { fn([u8]): Sized } yields { ...
true
3ef1d806d2d3520742277e880a625bb3b13eae2c
Rust
itto-ki/atcoder
/ABC/084/C.rs
UTF-8
2,134
2.84375
3
[]
no_license
macro_rules! input { ($ttype:ty) => { { let mut input = String::new(); let _= std::io::stdin().read_line(&mut input); input.trim().parse::<$ttype>().unwrap() } }; ($($ttype:ty),*) => { { use std::io::BufRead; let mut input ...
true
aae06165672d6870c5619f81932dd4d54e89a080
Rust
aitorfernandez/competitive-programming
/armstrong-numbers/src/lib.rs
UTF-8
705
3.3125
3
[]
no_license
pub fn is_armstrong_number(num: u32) -> bool { // let digits = num // .to_string() // .chars() // .map(|d| d.to_digit(10).unwrap()) // .collect::<Vec<_>>(); // if digits.len() >= 10 { // false // } else { // digits // .iter() // .fold(...
true
010eaece0c53eda172195144cc8e932bd4100e8e
Rust
dmgolembiowski/vssh
/src/cli.rs
UTF-8
4,533
3.0625
3
[ "MIT" ]
permissive
use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt( name = "vssh", author = "Alex Krantz <alex@alexkrantz.com>", version = crate::util::VERSION )] /// SSH into a server requiring a certificate signed by a Hashicorp Vault instance pub struct Opts { /// Sets a custom config file #[stru...
true
5848838967d60fa96ce18ce6e7f6df3d9fe43d4c
Rust
j-dong/lambda
/src/bin/beta.rs
UTF-8
3,798
3.078125
3
[]
no_license
extern crate lambda; use lambda::expr; use std::io; use std::io::{Read, Write}; use std::fs; fn main() { println!("beta reduction calculator"); println!(); println!("load FILE"); println!("set EXPR"); println!("beta [TIMES]"); println!("print"); println!("quit"); println!(); print...
true
77142f2890cfa7d46232b23d8a2a632635ea11a3
Rust
Palem1988/tock-on-titan
/h1b/src/hil/flash/fake.rs
UTF-8
6,144
2.96875
3
[ "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
true
a6e5d383de3f58a3973afe11d9e6bc8db865caf3
Rust
nautical/compyler
/src/codegen.rs
UTF-8
19,260
3.0625
3
[]
no_license
use program::*; use wexp::Wexp::{self, *}; pub struct CodeGenerator { program: Program, // functions, etc. } macro_rules! wasm { ($i:ident) => { ::wexp::Wexp::Atom(stringify!($i).to_string()) }; ($s:expr) => {{ let s: &str = $s; ::wexp::Wexp::Atom(s.to_string()) }}; } ...
true
a15d7aff2d389f9af2f658296f94f3f372925d3b
Rust
tjoskar/rust-wasm
/rust-bin/src/main.rs
UTF-8
170
3.609375
4
[]
no_license
fn main() { let result = fib(44); println!("Hello, world! {}", result); } fn fib(n: u32) -> u32 { if n < 3 { return 1; } return fib(n - 1) + fib(n - 2); }
true
880096657c2402e20ab32caee0be74054bec6f2d
Rust
anti-social/swindon
/src/chat/close_reason.rs
UTF-8
924
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
use tk_http::Status; #[derive(Debug, Clone, PartialEq)] pub enum CloseReason { /// Stopping websocket because respective session pool is stopped PoolStopped, /// Closing because respective http returned specified response code AuthHttp(Status), /// Closed by peer, we just propagate the message her...
true
454be8d5004b74f7bc0d5ef0d4ee91cdfa214a78
Rust
hatahet/timely-dataflow
/examples/hello.rs
UTF-8
689
2.84375
3
[ "MIT" ]
permissive
extern crate timely; use timely::dataflow::*; use timely::dataflow::operators::*; fn main() { // initializes and runs a timely dataflow computation timely::execute_from_args(std::env::args(), |computation| { // create a new input, and inspect its output let mut input = computation.scoped(move ...
true
ece16df73046860e33abbba81a623b4bea51ef8c
Rust
claudiucelfilip/drizzle-wavelet-test
/contract/src/lib.rs
UTF-8
1,389
2.578125
3
[]
no_license
use smart_contract::log; use schemars::{schema_for, JsonSchema}; use serde::{Deserialize, Serialize}; use smart_contract::payload::Parameters; use smart_contract::transaction::{Transaction, Transfer}; use smart_contract_macros::smart_contract; #[derive(Deserialize, JsonSchema)] struct SetDataParams { data: String ...
true
94fa21ba6e3f27302894cecee0c989cfc12c371a
Rust
Thrump/Stegan
/src/util.rs
UTF-8
796
2.59375
3
[]
no_license
extern crate steganography; use steganography::encoder::*; use steganography::decoder::*; use steganography::util::*; pub fn encode(input: String, message: String, output:String ){ let byte_mes = str_to_bytes(&message); let destination_image = file_as_dynamic_image(input.trim().to_string()); let enc = ...
true
05238b5c9fde77f71f776b7b387e9bd02ce417f8
Rust
mfs/rust-df
/src/main.rs
UTF-8
3,374
2.546875
3
[ "MIT" ]
permissive
extern crate clap; extern crate colored; extern crate nix; mod stats; mod util; use clap::{Arg, Command}; use colored::*; use nix::sys::statvfs::statvfs; use std::cmp; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::process; use stats::Stats; use util::{bargraph, iec, is_virtual}; const FS...
true
d12ce86d587281941bdccafd882a6c7cbb6f2dd2
Rust
jyotsna-penumaka/enarx
/memory/src/register.rs
UTF-8
10,388
2.53125
3
[ "Apache-2.0" ]
permissive
// SPDX-License-Identifier: Apache-2.0 macro_rules! implfrom { () => {}; ($attr:meta $f:ident => Register<$t:ident>) => { #[$attr] impl From<$f> for Register<$t> { #[inline] fn from(value: $f) -> Self { Self(value as _) } } }; ...
true
f05f766ccdfed60fedcfc6450fa8e638613a851a
Rust
smessmer/screeps-game-api
/src/memory.rs
UTF-8
10,051
3.8125
4
[ "MIT" ]
permissive
//! Interface with Screeps' `Memory` global variable //! //! Screeps' memory lives in the javascript `Memory` global variable and is //! encoded as a javascript object. This object's reference is tracked within //! rust as a `MemoryReference`. The [`root`] function gives access to a //! reference to the `Memory` global...
true
bf5aec3ca79cc521eab2c375ca9f141e899f45d5
Rust
ianrust/aoc2020
/src/day15.rs
UTF-8
2,722
3.65625
4
[]
no_license
use std::collections::HashMap; #[aoc_generator(day15)] pub fn input_generator(input: &str) -> Vec<u32> { input .split(",") .map(|n| n.trim().parse::<u32>().expect("unable to parse number")) .collect::<Vec<u32>>() } struct Lookup { ordered: Vec<u32>, unordered: HashMap<u32, u32>, } ...
true
f4918c724fa6b0f1a593269130c92be58fb6877e
Rust
koukyo1994/rust-robotics
/LNPR_BOOK/lnpr/src/mvtnorm.rs
UTF-8
916
2.703125
3
[ "MIT" ]
permissive
use ndarray::{Array1, Array2}; use ndarray_linalg::cholesky::*; use ndarray_linalg::lapack::UPLO; use ndarray_rand::rand_distr::StandardNormal; use ndarray_rand::RandomExt; pub fn mvtnorm<R: ndarray_rand::rand::RngCore>( rng: &mut R, mu: &Array1<f64>, cov: &Array2<f64>, ) -> Array1<f64> { let l = cov.c...
true
9c1da9840569e4673c41f1100110c2e5c285c380
Rust
ghishadow/scoop-rs
/crates/core/src/ops/search.rs
UTF-8
2,482
2.71875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::path::PathBuf; use std::sync::{Arc, Mutex}; use rayon::iter::IntoParallelIterator; use rayon::iter::ParallelIterator; use crate::manager::BucketManager; use crate::model::AvailableApp; use crate::util::leaf; use crate::Config; use crate::ScoopResult; /// Main method for `scoop search`. pub fn search<'cfg>( ...
true
454c1e7b17bbfb1043c925575034bed8dc182a6e
Rust
liambrownweb/Exercism.io_my_work
/rust/reverse-string/test.rs
UTF-8
131
2.859375
3
[]
no_license
fn main() { let str = "Hello, World!"; let rev_str = str.chars().rev().collect::<String>(); println!("{}", rev_str); }
true
4d282a2ec1dbfae832f72bf9722b251e67fd10bf
Rust
PoiScript/orgize
/src/elements/list.rs
UTF-8
6,374
3.234375
3
[ "MIT" ]
permissive
use std::borrow::Cow; use std::iter::once; use memchr::{memchr, memchr_iter}; use nom::{ branch::alt, bytes::complete::tag, character::complete::{digit1, space0}, combinator::{map, recognize}, sequence::terminated, IResult, }; /// Plain List Element #[cfg_attr(test, derive(PartialEq))] #[cfg_a...
true
6cd2403edc5c6f43630a22ce435e0286f2346269
Rust
aatxe/fehler
/fehler-macros/src/throws.rs
UTF-8
4,756
2.84375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use proc_macro::*; use syn::fold::Fold; struct Throws { ty: syn::Type, outer_fn: bool, } pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { let ty = if args.is_empty() { syn::parse2(quote::quote!(::fehler::Exception)).unwrap() } else { syn::parse(args).unwrap_or_else(...
true
3d6aa541a34448278aa5105e53d7814f9882eead
Rust
amigo-rich/linux-battery-info
/src/error.rs
UTF-8
1,433
3.21875
3
[ "MIT" ]
permissive
use std::path::PathBuf; #[derive(Debug)] pub enum Error { /// A &str to enum conversion error. TryFromConversion, /// A wrapper around a std::io::Error. IOError(std::io::Error), /// The content of a requested file is empty. SysFsBatteryItem, /// A requested file is either not a file, or doe...
true
9c7ce72af784e335a2ba02a927126139d39016b7
Rust
brain0/binomial-rs
/tests/binomial15.rs
UTF-8
1,041
2.765625
3
[]
no_license
extern crate binomial; use binomial::Binomial; const BINOMIAL_15: [usize; 16] = [ 1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1 ]; #[test] fn b15_usize() { for (i, &v) in BINOMIAL_15.iter().enumerate() { assert_eq!(15usize.choose(i).unwrap(), v); } } #[test] fn ...
true
7e9287a5ced1b2b7d6d8ceb721a4862aa648468b
Rust
Kneelawk/kpipes
/kpipes-core/src/render/buffer.rs
UTF-8
8,739
2.59375
3
[ "MIT" ]
permissive
use bytemuck::{cast_slice, Pod}; use std::{marker::PhantomData, mem::size_of}; use wgpu::{Buffer, BufferAddress, BufferAsyncError, BufferDescriptor, BufferUsages, CommandBuffer, CommandEncoderDescriptor, Device, Maintain, MapMode}; use crate::render::util::least_power_of_2_greater; /// Statically-sized wrapper around ...
true
e95010898eca2d40fb92318a34c07c5648bad93c
Rust
goodrone/project-euler-rust
/029/main.rs
UTF-8
945
3.703125
4
[ "MIT" ]
permissive
use std::collections::HashSet; fn prime_powers(x: u64) -> (u64, u64) { match x { 4 => (2, 2), 8 => (2, 3), 16 => (2, 4), 32 => (2, 5), 64 => (2, 6), 9 => (3, 2), 27 => (3, 3), 81 => (3, 4), 25 => (5, 2), 49 => (7, 2), _ => (x, ...
true
1a23e02c6bd7f6b2637d16e8567f940d539cfb1b
Rust
ivandpoetra/OS_Rust_Exercism
/perfect-numbers/src/lib.rs
UTF-8
849
3.375
3
[]
no_license
#[derive(Debug, PartialEq, Eq)] pub enum Classification { Abundant, Perfect, Deficient, } pub fn classify(num: u64) -> Option<Classification> { if num == 0{ None } else if num > 0 { if aquilot_sum(num) == num { return Some(Classification::Perfect) } ...
true
aa82701170ca1b8ae602c5abb82232900e1b0568
Rust
iCodeIN/raytracer-rs
/src/material/mod.rs
UTF-8
1,333
2.921875
3
[]
no_license
pub use crate::material::checker::Checker; pub use crate::material::texture::{Texture, TextureCoord}; use crate::color::Color; use crate::math::Point3D; mod checker; mod texture; #[derive(Debug, Clone, Copy, PartialEq)] pub enum Surface { Diffuse, Reflective(f64), Refractive { index: f64, transparency: f...
true
372973404aa570dde5d21d0b5eea131ca3bb053b
Rust
AngryLawyer/a-dabblers-adventures-in-rust
/snippets/pointers.rs
UTF-8
638
3.109375
3
[ "MIT" ]
permissive
fn main () { //---START:1 struct Kitty { fluffiness: uint }; fn new_kitty(fluffiness: uint) -> Kitty { Kitty{fluffiness: fluffiness} }; let buffcat = new_kitty(2); //On the stack //---END:1 //---START:2-1 let tom = ~new_kitty(3); //They're guaranteed unique - you can move t...
true
ee26144a6380e605b9519e1e1c899e5babb883e5
Rust
DirtGrubDylan/tic_tac_toe
/src/game.rs
UTF-8
10,188
3.96875
4
[ "MIT" ]
permissive
//! This a module for setting up a game of Tic-Tac-Toe. //! //! It contains an aliased type for the game board, an enum for the game turn, and a struct for the //! game itself. use rand; use std::io; /// The game board as an aliased type. type Board = Vec<Vec<String>>; /// A turn in the game as an Enum. #[derive(Debu...
true
775144d866e70d4b29c6386cb25a29ebdb5499d2
Rust
stm32-rs/stm32-rs-nightlies
/stm32l4/src/stm32l4p5/usart1/gtpr.rs
UTF-8
2,353
2.59375
3
[]
no_license
#[doc = "Register `GTPR` reader"] pub type R = crate::R<GTPR_SPEC>; #[doc = "Register `GTPR` writer"] pub type W = crate::W<GTPR_SPEC>; #[doc = "Field `PSC` reader - Prescaler value"] pub type PSC_R = crate::FieldReader; #[doc = "Field `PSC` writer - Prescaler value"] pub type PSC_W<'a, REG, const O: u8> = crate::Field...
true
a00add87eafdfbf0aad03037004f564652240ae4
Rust
spaans/inquirer-rs
/examples/enumerated-list.rs
UTF-8
317
3.265625
3
[ "MIT" ]
permissive
extern crate inquirer; use inquirer::list; fn main() { let choices: Vec<_> = vec!["Red", "Blue", "Green"].into_iter() .enumerate() .map(|(index, item)| (item, index)) .collect(); let result = list("Choose an option:", &choices).unwrap(); println!("You chose {:?}.", result); }
true
0a9a47e3d42744c75a1be7fe9f2dee6126ef6f14
Rust
jiangyinzuo/icpc
/exercise/rust_exercise/src/bin/cf1438b.rs
UTF-8
645
2.859375
3
[]
no_license
fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let t: i32 = s.trim().parse().unwrap(); for _ in 0..t { std::io::stdin().read_line(&mut s).unwrap(); s.clear(); let mut map = std::collections::HashSet::new(); std::io::stdin().read_line(&...
true
f17553d2a13b55877cd19d110143dd960319d5b7
Rust
Ninjani/rosalind
/s_seto/src/lib.rs
UTF-8
1,653
3.21875
3
[ "MIT" ]
permissive
use std::collections::HashSet; use std::iter::FromIterator; use anyhow::Error; use std::path::Path; /// Introduction to Set Operations /// /// Given: A positive integer n (n≤20,000) and two subsets A and B of {1,2,…,n}. /// /// Return: Six sets: A∪B, A∩B, A−B, B−A, Ac, and Bc /// (where set complements are taken wit...
true
52b53bb72d7397b5b90c83681acc69923ad01377
Rust
partkyle/destiny-lights-out
/src/game.rs
UTF-8
9,417
3.140625
3
[]
no_license
use piston_window::{clear, rectangle, Button, Context, GenericEvent, Graphics, MouseButton}; pub enum GameState { Running, Quit, } pub struct Colors { background: [f32; 4], slot_color: [f32; 4], } impl Colors { pub fn new() -> Colors { Colors { // converting all of these from ...
true
8ffa4f7659c1fccf1d8a39bdc345ab95d1c21a9c
Rust
lfdominguez/elastic
/src/elastic/src/client/responses/tests/nodes_info/mod.rs
UTF-8
707
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{ client::responses::*, http::{ receiver::parse, StatusCode, }, }; #[test] fn deserialise_nodes() { let f = include_bytes!("nodes_info.json"); let deserialized = parse::<NodesInfoResponse>() .from_slice(StatusCode::OK, f as &[_]) .unwrap(); let expect...
true
187819b4946a2eeecc292f3be79df42868611d70
Rust
IThawk/rust-project
/rust-master/src/test/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs
UTF-8
451
2.875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// Test that we do not ICE when the self type is `ty::err`, but rather // just propagate the error. #![crate_type = "lib"] #![feature(lang_items)] #![feature(no_core)] #![no_core] #[lang="sized"] pub trait Sized { // Empty. } #[lang = "add"] trait Add<RHS=Self> { type Output; fn add(self, _: RHS) -> Sel...
true
437bb4f2e8e0b5f924c9bdfbf1ef86c328e39593
Rust
Kevin-Xi/learning_playground
/rust/book/b7_example/src/lib.rs
UTF-8
714
2.828125
3
[ "MIT" ]
permissive
mod outermost { pub fn middle_function() {} // private, can only access by current module(outermost) and its children(inside) fn middle_secret_function() {} mod inside { pub fn inner_function() { // need import ... use outermost::middle_function; middle_func...
true
706b0e18da56ece861c81f97e7f700da5beb450e
Rust
5achinJani/prisma
/server/libs/jwt-native-rs/src/ffi_utils.rs
UTF-8
1,823
3.125
3
[ "Apache-2.0" ]
permissive
use std::ffi::{CStr, CString}; use std::os::raw::c_char; ///////////////// // Rust -> JVM // ///////////////// /// We need to honor zero termination. Might lead to reallocation. pub fn string_to_ptr(s: String) -> *mut c_char { let cs: CString = CString::new(s).unwrap(); cs.into_raw() } ///////////////// // J...
true
02f3a852b18a59721eef010992696c2f2f749821
Rust
HaoranYi/gitProj
/rust_playpen/src/trait_ex.rs
UTF-8
1,176
3.5
4
[]
no_license
/// example of traits composition (dependency injection) trait Speaks { fn speak(&self); } trait Animal { fn kind(&self) -> &str; fn noise(&self) -> &str; } impl<T: Animal> Speaks for T //where // T: Animal, { fn speak(&self) { println!("the {} said {},", self.kind(), self.noise()); } ...
true
20b2db5344d9ced493018aede205b53e7181b609
Rust
geo-ant/fluent-comparisons
/src/tests/any_of.rs
UTF-8
4,314
3.53125
4
[ "MIT" ]
permissive
#![allow(clippy::int_plus_one)] #![allow(clippy::many_single_char_names)] #![allow(clippy::assertions_on_constants)] use crate::any_of; use rand::prelude::*; use std::cell::Cell; use std::ops::Mul; // a helper function that squares its argument fn square<T: Mul<Output = T> + Copy>(val: T) -> T { val * val } #[te...
true
e094a88a3436fae46f9ee7d8dc77da5ca7c9dfa2
Rust
caibirdme/leetcode_rust
/src/prob_423.rs
UTF-8
1,407
3.390625
3
[ "MIT" ]
permissive
impl Solution { pub fn original_digits(s: String) -> String { let mut count = [0; 26]; for &c in s.as_bytes() { count[(c-b'a') as usize] += 1; } let mut number = [0; 10]; // the order is very critical let unique = vec![ (b'w', "two", 2), ...
true
c7cc4e6c9ce5007a03ad87f53c93c8b2e5553430
Rust
frangte/massbitprotocol
/indexer/manifest-reader/src/core.rs
UTF-8
865
2.703125
3
[]
no_license
use thiserror::Error; use std::fs::File; use anyhow::anyhow; use log::info; #[derive(Error, Debug)] pub enum ManifestValidationError { #[error("manifest has no data sources")] NoDataSources, #[error("manifest cannot index data from different networks")] MultipleNetworks, } // Lazily load file from loc...
true
66529eac7c5bc7a8a5272c1251fbdee2811c4a70
Rust
jdato/ngrok_simple
/src/main.rs
UTF-8
826
2.625
3
[ "MIT" ]
permissive
mod ngrok; use url::Url; fn main() -> std::io::Result<()> { let host = std::env::var("HOST").expect("Expected hostname."); let port = std::env::var("PORT").expect("Expected port."); let auth = std::env::var("AUTH").expect("Expected auth crendentials in format 'usr:pwd'."); let authtoken = std::env::var...
true
f5267519fd636cd6a227d85b024e11a0a45b85aa
Rust
unseddd/cryptopals
/tests/set_four/mod.rs
UTF-8
25,903
2.78125
3
[ "WTFPL" ]
permissive
use std::thread::sleep; use std::time; use rand::{thread_rng, Rng}; use cryptopals::mac::hmac_sha1; #[test] fn challenge_twenty_five() { use crate::common::read_lines; use cryptopals::ctr::edit; use cryptopals::encoding::from_base64; let editor = edit::EditCtr::new(); let b64 = read_lines("tests...
true
634ffd55e99710cfe52836983ab0d1131429092a
Rust
xoac/influxdb-line-protocol
/src/field.rs
UTF-8
9,417
2.796875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::{ error::Error, escape, name_restriction::{prevent_filed_value_string, prevent_key}, }; use derive_more::{Deref, Display, From}; use ordered_float::NotNan; use std::{ borrow::Borrow, convert::{TryFrom, TryInto}, }; #[cfg(feature = "serde")] use serde1::{ de::{self, Error as Deserial...
true
d487b13d41d41c1a831c449403dba987568fee4b
Rust
michalczaplinski/rust-ownership
/rs/race/src/main.rs
UTF-8
360
3.15625
3
[]
no_license
use std::thread; fn main() { let mut a: u64 = 0; let one = thread::spawn(|| { for i in 1..50_000_000 { a = a + i; } }); let two = thread::spawn(|| { for i in 50_000_000..=100_000_000 { a = a + i; } }); one.join().unwrap(); two.join(...
true
ca59b74470d704cc8b7bb46b9abbe8507f173cba
Rust
HiruNya/cordis
/cordis-core/src/resources/channel/guild_store.rs
UTF-8
572
3.09375
3
[ "MIT" ]
permissive
use super::super::{ChannelId, GuildId, MessageId}; /// A channel in which game developers can sell their game on Discord. pub struct GuildStoreChannel { /// The id of this channel. pub id: ChannelId, /// The id of the guild. pub guild_id: GuildId, /// Sorting position of the channel. pub positi...
true
7626900b9e43fa1bbf27acbfcc9e6dda2cbab5e2
Rust
sdroege/gst-plugin-rs
/generic/threadshare/src/runtime/executor/context.rs
UTF-8
18,265
2.625
3
[ "MIT", "MPL-2.0", "Apache-2.0", "LGPL-2.1-or-later", "LicenseRef-scancode-unknown-license-reference", "LGPL-2.0-only", "LGPL-2.1-only" ]
permissive
// Copyright (C) 2018-2020 Sebastian Dröge <sebastian@centricular.com> // Copyright (C) 2019-2022 François Laignel <fengalin@free.fr> // // Take a look at the license at the top of the repository in the LICENSE file. use futures::prelude::*; use gst::glib::once_cell::sync::Lazy; use std::collections::HashMap; use st...
true
fbe2a89f4609b8bdfe520692c753c79cc786ddbe
Rust
AlexEales/simple-wasm-ga
/crate/src/lib.rs
UTF-8
4,433
3.140625
3
[ "Apache-2.0", "MIT" ]
permissive
use wasm_bindgen::prelude::*; use rand::prelude::*; use std::{char, u8, f64}; // TODO: CLEAN UP THIS WHOLE DAMN THING // TODO: ERROR CHECK THIS WHOLE DAMN THING. // TODO: DOCUMENT THIS WHOLE DAMN THING. #[wasm_bindgen] pub struct GASimulation { target_colour: String, population_size: u16, mutation_rate: f3...
true
2b95bff6971c04682a7c13edfdbc91342d3f7dd6
Rust
zaeleus/noodles
/noodles-vcf/src/record/value.rs
UTF-8
464
2.765625
3
[ "MIT" ]
permissive
use std::{borrow::Cow, str}; use percent_encoding::percent_decode_str; pub(crate) fn percent_decode(s: &str) -> Result<Cow<'_, str>, str::Utf8Error> { percent_decode_str(s).decode_utf8() } #[cfg(test)] mod tests { use super::*; #[test] fn test_percent_decode() -> Result<(), str::Utf8Error> { ...
true
699ad2b676dad314aea5b6278109cf0dedb55b58
Rust
andrewwhitehead/async-resource-rs
/async-resource/tests/utils/mod.rs
UTF-8
1,028
3.28125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::sync::atomic::{AtomicUsize, Ordering}; pub struct AtomicCounter { count: AtomicUsize, } #[allow(unused)] impl AtomicCounter { pub fn new(val: usize) -> Self { Self { count: AtomicUsize::new(val), } } pub fn increment(&self) -> usize { self.count.fetch_add(...
true
0a7d467b700ef162c55313569c0ad9e075407baf
Rust
0x1a8510f2/MxSelfBot
/src/log.rs
UTF-8
741
2.8125
3
[ "Apache-2.0" ]
permissive
/* MxSelfBot by 0x1a8510f2 Module to help with logging events */ #[derive(Debug)] pub enum LogLevel { Info, Warn, Error, } impl std::fmt::Display for LogLevel { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", format!("{:?}", self).to_uppercase()) } } #[d...
true
f0c5af2017564f713ff1a1bd33dbf7f873baac71
Rust
dkijania/rust-bdd
/src/api/error.rs
UTF-8
839
2.5625
3
[]
no_license
use reqwest::{ header::{InvalidHeaderName, InvalidHeaderValue}, Error as ReqwestError, }; use std::env::VarError; use thiserror::Error; #[derive(Error, Debug)] pub enum Error { #[error("{0}")] ErrorResponse(String), #[error("request error: {0}")] RequestError(#[from] ReqwestError), #[error(...
true
98c3a94f444ab45266a22389dc1ae63ea61f5ebe
Rust
franktea/leetcode-rust
/src/bin/0086.rs
UTF-8
1,097
3.515625
4
[]
no_license
#[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>> } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } impl Solution { pub fn partition(head: Option<Box<ListNode>>, x: i32) -> Optio...
true
d234bea5bf6f85e6959d9d02f58876bc4699fc5a
Rust
ayush6624/rust-lang
/src/main.rs
UTF-8
419
3.03125
3
[]
no_license
use std::{usize}; use text_io::read; mod bubble; mod insertion; fn main(){ println!("Implementing differnt sorting algorithms in rust"); let n : i32 = read!(); let mut arr : Vec<i32> = vec![0; n as usize]; println!("{}", arr.len()); for i in 0..arr.len(){ arr[i] = read!(); } println!...
true
d74cd2a080bb6cc5e7e07b6ca35639ecc7b710a6
Rust
StappsWorld/YALAL
/src/lib.rs
UTF-8
13,560
3.6875
4
[ "MIT" ]
permissive
// Work by Samuel Rembisz 2021 //! # Yet Another Linear Algebra Library //! A helper library for Linear Algebra functions and data structures. It provides Vectors and Matrices for developers to use in their projects. //! //! //! As an ease of use, the library provides Vectors and a Matrix structs. //! //! ## Vectors /...
true
50fe605d915fd38b327ef11ee28db67b04f938f3
Rust
ian-pacheco/RustCrashCourse
/src/functions.rs
UTF-8
1,500
4
4
[]
no_license
// Functions - Used to store blcoks of code for re use pub fn run() { greeting("Hello", "Jane"); // Bind fn values to variables let get_sum = add(5,5); println!("Sum: {}", get_sum); // Closure let n3: i32 = 10; let add_nums = |n1: i32, n2: i32| n1 + n2 + n3; println!("C sum: {}", add_nums(3,3)); } fn greeting(greet...
true
f6f603065351f5e5ea4c011b67afddd8875043af
Rust
arn-the-long-beard/proto-seeder
/src/parser/mod.rs
UTF-8
3,453
2.828125
3
[ "MIT" ]
permissive
//! Parser that share similarities with code in [seed_routing](https://github.com/arn-the-long-beard/seed-routing). //! It will extract variants and attributes from Routes enum. use syn::{ Attribute, Error, Item, ItemEnum, ItemFn, ItemMod, ItemStruct, Lit, LitStr, Meta, MetaNameValue, Result, }; pub mod modul...
true
e8627a6d6ed50c2757e4254be6dba7735e9ba96a
Rust
lbovet/iced
/web/src/clipboard.rs
UTF-8
524
3.40625
3
[ "MIT" ]
permissive
/// A buffer for short-term storage and transfer within and between /// applications. #[derive(Debug, Clone, Copy)] pub struct Clipboard; impl Clipboard { /// Creates a new [`Clipboard`]. pub fn new() -> Self { Self } /// Reads the current content of the [`Clipboard`] as text. pub fn read(...
true
3023a0e58ccd4cdc487ce381ea3e1cedafad351f
Rust
lpil/decksterity
/src/midi/mod.rs
UTF-8
1,898
2.71875
3
[]
no_license
use midir::{Ignore, MidiInput, MidiInputConnection}; use std::sync::{Arc, Mutex}; use super::engine::Engine; type Ctrl = (u8, u8); const PITCH_STEP: f64 = 0.00_02; const TOP_ENCODER_4_TURN: Ctrl = (190, 3); const TOP_ENCODER_4_PRESS: Ctrl = (158, 55); const SLIDER_4: Ctrl = (190, 19); pub fn connect_xone_k2(engine: ...
true
2df4f31ad697cc91758b504a0cebc368c0030f2b
Rust
alex-dukhno/rust-tdd-katas
/old-katas-iteration-01/test/map_kata/day_4.rs
UTF-8
862
3.25
3
[ "MIT" ]
permissive
pub use tdd_kata::map_kata::day_4::Map; #[test] fn it_should_create_a_new_empty_map() { let map = Map::new(10); assert!(map.is_empty()); assert_eq!(map.size(), 0); } #[test] fn it_should_increase_size_when_put_value() { let mut map = Map::new(10); let old_size = map.size(); map.put(1,1); ...
true
6e635feda8cb762a7bdf10c547d90d6c9311ab0e
Rust
GrossBetruger/exercism
/rust/linked-list/src/main.rs
UTF-8
281
3.4375
3
[]
no_license
struct Node<T> { data: T, next: Option<Box<Node<T>>> } struct LinkedList<T> { head: Option<Node<T>>, } fn main() { let list = LinkedList { head: Some(Node { data: 1, next: None }) }; println!("Hello, world!"); }
true
5731d96ec7dd382ce06f1911d610a9196fe8b5df
Rust
garfieldnate/ray_tracer_challenge
/lib/src/canvas.rs
UTF-8
12,383
3.34375
3
[ "MIT" ]
permissive
use crate::color::Color; use std::collections::VecDeque; use std::io::{self, BufRead, BufReader, Read}; #[derive(Clone, Debug)] pub struct Canvas { pub width: usize, pub height: usize, data: Vec<Vec<Color>>, } const MAX_COLOR_VAL: u16 = 255; const MAX_PPM_LINE_LENGTH: usize = 70; // length of "255" is 3 /...
true
3cfb31f2ad4ab3e05951ac242cbb1adaacd5c9c9
Rust
mikowitz/forte
/src/prime_form.rs
UTF-8
1,195
3.015625
3
[]
no_license
use crate::{normal_form, utils, PitchClassSet}; use std::cmp::min; pub fn from(set: &PitchClassSet) -> Vec<u32> { let nf: PitchClassSet = normal_form::from(set); let intervals: Vec<u32> = utils::intervals(nf.set()); let mut reversed = intervals.clone(); reversed.reverse(); let mut left_packed = min...
true