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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
85b6b5b591fb8663fbb3aae9b3056207e9f98111 | Rust | matklad/rust-analyzer | /crates/ide_completion/src/completions/fn_param.rs | UTF-8 | 3,883 | 3.03125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! See `complete_fn_param`.
use rustc_hash::FxHashMap;
use syntax::{
ast::{self, ModuleItemOwner},
match_ast, AstNode,
};
use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions};
/// Complete repeated parameters, both name and type. For example, if all
/// functions i... | true |
541cf0e5e3cb5a171b8227c74458304da2bd3bdb | Rust | oday0311/imkey-core | /api/src/filecoin_address.rs | UTF-8 | 906 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use crate::api::{AddressParam, AddressResult};
use crate::error_handling::Result;
use crate::message_handler::encode_message;
use coin_filecoin::address::FilecoinAddress;
use prost::Message;
pub fn get_address(param: &AddressParam) -> Result<Vec<u8>> {
let address = FilecoinAddress::get_address(param.path.as_ref()... | true |
5d9d9131d02473acb5556378047ab922c88a8012 | Rust | NYStud/hedr | /src/file_sel.rs | UTF-8 | 8,433 | 2.921875 | 3 | [
"MIT"
] | permissive |
use std::fs;
use std::io;
use std::path::PathBuf;
use std::cmp::Ordering;
use std::ffi::{OsString, OsStr};
use super::screen::*;
use super::term::*;
use super::editor;
use super::editor::Editor;
#[derive(Eq)]
struct FileInfo {
pub name : OsString,
pub is_dir : bool,
}
impl Ord for FileInfo {
fn cmp(&se... | true |
37ffff8cb085b4142e431eee7088792503c966f2 | Rust | IThawk/rust-project | /rust-master/src/test/ui/numbers-arithmetic/float.rs | UTF-8 | 244 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
pub fn main() {
let pi = 3.1415927f64;
println!("{}", -pi * (pi + 2.0 / pi) - pi * 5.0);
if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0
|| pi > 1.0 {
println!("yes");
}
}
| true |
a7cdccde0c3d21bd7bac36fd29902b24c0a268b1 | Rust | ytakhs/leetcode-rs | /examples/archives/sum_of_root_to_leaf_binary_numbers.rs | UTF-8 | 2,443 | 3.453125 | 3 | [] | no_license | #[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
TreeNode {
val,
left: None,
right: None,
... | true |
da86e371cd4f6de7a15e70731beb2df9aeffb382 | Rust | decentninja/RustRelations | /src/lib.rs | UTF-8 | 3,528 | 3.28125 | 3 | [] | no_license | use std::collections::HashSet;
trait Relation<T, W> {
fn operation(&self, a: T, b: T) -> bool;
fn is_transitive(&self) -> bool;
fn is_reflexive(&self) -> bool;
fn is_symetric(&self) -> bool;
fn is_equivalence(&self) -> bool {
self.is_symetric() && self.is_reflexive() && self.is_transitive()
}
/// Test if... | true |
55264f4ccaffa57d843cdf867793b32755a2eee2 | Rust | AtomicMegaNerd/pig_latin | /src/main.rs | UTF-8 | 224 | 2.953125 | 3 | [] | no_license | use pig_latin::pig_latinize;
fn main() {
println!("{}", pig_latinize("Hello again, out there wonderful world"));
println!(
"{}",
pig_latinize("Today is a fantastic day, and I am so happy!")
);
}
| true |
14f43703a55872e7e34efeb076edf0b5b4f33622 | Rust | tinmarino/libnotcurses-sys | /src/cell/test/reimplemented.rs | UTF-8 | 3,267 | 2.59375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Test `cell*_*` reimplemented functions
use serial_test::serial;
use crate::{c_api, NcAlpha, NcAlphaApi, NcCell};
#[test]
#[serial]
fn rgb() {
// rgb
let mut c1 = NcCell::new();
assert_eq![0, c_api::nccell_fg_rgb(&c1)];
assert_eq![0, c_api::nccell_bg_rgb(&c1)];
c_api::nccell_set_fg_rgb(&mut ... | true |
46e5be9634deb6d90b6d6a152dc3d79ae0146077 | Rust | robjtede/adventofcode2017 | /day9b/src/main.rs | UTF-8 | 640 | 2.65625 | 3 | [] | no_license | extern crate day9b as lib;
use std::env;
use std::process;
use lib::count_garbage;
use lib::config::Config;
use lib::parser::{get_input, parse_input};
fn main() {
let config = Config::new(env::args()).unwrap_or_else(|err| {
println!("Problem parsing arguments: {}", err);
process::exit(1);
});... | true |
722ee177b01e063cf49b92758bc1da47b21daaa7 | Rust | loyston500/CodeGodRust | /bot/src/commands/misc.rs | UTF-8 | 2,698 | 3.03125 | 3 | [] | no_license | use std::time::{Duration, SystemTime};
use serenity::client::Context;
use serenity::framework::standard::{macros::command, Args, CommandResult};
use serenity::model::channel::Message;
use crate::Database;
/// tells the ping (heart beat)
#[command]
pub async fn ping(ctx: &Context, msg: &Message) -> CommandResult {
... | true |
6fb80fe6f3f0c9a8bd410a591bb9706d29fbe7e5 | Rust | Laastine/hinterland | /src/zombie/zombies.rs | UTF-8 | 3,232 | 2.6875 | 3 | [
"GPL-1.0-or-later",
"Apache-2.0"
] | permissive |
use crate::shaders::Position;
use crate::zombie::ZombieDrawable;
pub struct Zombies {
pub zombies: Vec<ZombieDrawable>,
}
impl Zombies {
pub fn new() -> Zombies {
Zombies {
zombies: vec![
// 1
ZombieDrawable::new(Position::new(500.0, 40.0)),
ZombieDrawable::new(Position::new(-50... | true |
82691d876f08bc28fe49a06a193e90b0c54fcb47 | Rust | keesvv/boltchat-rs | /src/events/event.rs | UTF-8 | 742 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::time::{SystemTime, UNIX_EPOCH};
use serde::{Deserialize, Serialize};
/// Eventmeta that is appended to every event.
#[derive(Serialize, Deserialize, Debug)]
pub struct EventMeta {
pub t: String,
pub c: u64,
}
impl EventMeta {
pub fn new(t: &str) -> Self {
EventMeta {
t: String::from(t),
c: ... | true |
de78e7aedd9bcdea034486514ecb86588a99f6ed | Rust | edouardparis/opennode-rs | /opennode-client/src/lib.rs | UTF-8 | 2,559 | 2.515625 | 3 | [
"MIT"
] | permissive | pub mod client;
pub mod error;
use opennode::account::{Balance};
use opennode::charge;
use opennode::charge::Charge;
use opennode::withdrawal;
use opennode::withdrawal::Withdrawal;
use opennode::refund;
use opennode::refund::Refund;
use opennode::currency::Currency;
use opennode::rate::Rates;
use crate::client::Clien... | true |
4cc0b107f1ae31c45d26490a273ec73641ec6654 | Rust | TimelyDataflow/differential-dataflow | /src/algorithms/graphs/scc.rs | UTF-8 | 2,194 | 2.625 | 3 | [
"MIT"
] | permissive | //! Strongly connected component structure.
use std::mem;
use std::hash::Hash;
use timely::dataflow::*;
use ::{Collection, ExchangeData};
use ::operators::*;
use ::lattice::Lattice;
use ::difference::{Abelian, Multiply};
use super::propagate::propagate;
/// Iteratively removes nodes with no in-edges.
pub fn trim<G... | true |
156d7378bbd81ca228a14c54fd4a6899479f435f | Rust | jacobmischka/adventofcode-2020 | /src/bin/13.rs | UTF-8 | 2,162 | 2.96875 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let mut lines = stdin.lock().lines();
let earliest_timestamp: u32 = lines.next().unwrap().unwrap().parse().unwrap();
let bus_ids: Vec<Option<u32>> = lines
.next()
.unwrap()
.unwrap()
.split(',')
... | true |
96b722c09c84261664671bb7be56f5a94d2d245b | Rust | LoggedFuSkater/rust | /tests/implementation_test.rs | UTF-8 | 2,416 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate logged_fu_skater;
#[cfg(feature = "default-implementations")]
use logged_fu_skater::Obfuscateable;
#[test]
fn test_default_implementation() {
for test in TEST_CASES {
let result = test.input.obfp(test.padding);
assert_eq!(&result, test.expected_result, "input: {},\npadding: {}",test... | true |
f841c3b2ed39003abd31d0dc2475384074ade6db | Rust | oatley/rust-programs | /arrays/src/main.rs | UTF-8 | 302 | 3.53125 | 4 | [] | no_license | fn main() {
// Arrays are fixed length, same type items
let arrr = [1,2,3,4,5];
println!("First: {}, Last: {}", arrr[0], arrr[4]);
// Set a specific type with syntax [type; length]
let arrr2: [i64; 3] = [10,11,12];
println!("First: {}, Last: {}", arrr2[0], arrr2[2]);
}
| true |
cf76b53143ee6cd38d850c4ed5a0557b45be989c | Rust | liuchengxu/vim-clap | /crates/cli/src/command/blines.rs | UTF-8 | 2,959 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use crate::app::Args;
use anyhow::Result;
use clap::Parser;
use filter::SequentialSource;
use maple_core::paths::AbsPathBuf;
use matcher::{Bonus, MatchResult};
use rayon::iter::ParallelBridge;
use std::borrow::Cow;
use std::io::BufRead;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use types::Clap... | true |
957ea60676c41602711e4e0684c808b1447ec6a6 | Rust | valarauca/grpc-example | /grpc-examples/src/bin/greeter_client.rs | UTF-8 | 1,650 | 2.875 | 3 | [
"MIT"
] | permissive | extern crate grpc_examples;
extern crate grpc;
extern crate futures;
use futures::{Async,Stream};
use grpc_examples::helloworld_grpc::*;
use grpc_examples::helloworld::*;
use std::env;
use std::time::Duration;
use std::thread;
struct Name {
name: String
}
impl From<String> for Name {
fn from(name: String) -... | true |
d9611738363e7f9592354397d23b4f98c4ca572b | Rust | nilq/foon | /src/main.rs | UTF-8 | 397 | 2.890625 | 3 | [
"MIT"
] | permissive | mod foon;
use foon::*;
fn main() {
let test = r#"
[i32; 2]: a = {10, 10}
mut [i32; 2]: b =
10000
b =
b - 100
"#;
let lexer = lexer(&mut test.chars());
let traveler = Traveler::new(lexer.collect());
let mut parser = Parser::new(traveler);
match parser.parse() {
Err(why) => printl... | true |
4588ce3f07083cbe13e514e22bc3496cf0cefd18 | Rust | beewyka819/Advent-of-Code-2020 | /day-1/src/main.rs | UTF-8 | 1,639 | 3.328125 | 3 | [] | no_license | use std::{fs::File, io::Read, path::Path, str::FromStr};
fn main() {
let input = read_file_to_string("input.txt".to_string());
let nums = input
.lines()
.map(|i| i32::from_str(i).unwrap())
.collect::<Vec<i32>>();
let dual_pairs = tuple_pairs_two(&nums);
let (x, y) = *dual_pai... | true |
a9c47d55499dff3d3b2ef73c4393da64bfd7b704 | Rust | Sasszem/rttt | /src/game/ai/smart.rs | UTF-8 | 2,001 | 3.5625 | 4 | [] | no_license | //! Hard AI
use super::super::board::Board;
use super::super::enums::Symbol;
use super::AI;
use rand::Rng;
/// Hard AI
///
/// Strategy:
/// - winning move if there is one
/// - blocking player's winning move
/// - random corner
/// - random edge
/// - center
pub struct SmartAI {}
impl AI for SmartAI {
fn do_mov... | true |
ba94f59460d44b4b63f85ba08066d4e148f95d3d | Rust | expenses/nebulawar | /src/systems/rendering.rs | UTF-8 | 12,749 | 2.515625 | 3 | [] | no_license | use crate::util::*;
use specs::*;
use crate::components;
use crate::context::*;
use super::*;
use cgmath::Matrix4;
pub struct ObjectRenderer;
impl<'a> System<'a> for ObjectRenderer {
type SystemData = (
Write<'a, ModelBuffers>,
ReadStorage<'a, Position>,
ReadStorage<'a, components::Rotatio... | true |
f8eed20bc20f8e14b747da18b33c877401ca5c0d | Rust | cpfiffer/code | /rustbook/src/main.rs | UTF-8 | 277 | 3.078125 | 3 | [] | no_license | mod consts;
use std::collections::HashMap;
fn main() {
println!("Hello, world!");
let mut map = HashMap::new();
map.insert(consts::HELLO, consts::WORLD);
for (key, value) in &map {
println!("{} {}", key, value);
println!("What fun.")
}
}
| true |
9579c657622ede975b9f746f49a5f9e582cd64f6 | Rust | AtsukiTak/bitcoinrs | /src/lib/blockchain/block.rs | UTF-8 | 1,940 | 2.703125 | 3 | [] | no_license | use bitcoin::blockdata::{block::{Block, BlockHeader}, constants::genesis_block};
use bitcoin::network::{constants::Network, serialize::BitcoinHash};
use bitcoin::util::hash::Sha256dHash;
#[derive(Copy, Debug, Clone, PartialEq, Eq)]
pub struct BlockData
{
pub header: BlockHeader,
pub height: u32,
hash: Sha2... | true |
0bb51b067c10d967481806572d00bf0803d24add | Rust | n8henrie/exercism-exercises | /rust/minesweeper/src/lib.rs | UTF-8 | 1,630 | 3.09375 | 3 | [
"MIT"
] | permissive | fn get_adjacent_count(pos: (usize, usize), minefield: &[Vec<char>]) -> u32 {
let min_x = pos.0.saturating_sub(1);
let min_y = pos.1.saturating_sub(1);
let max_x = {
let newx = pos.0 + 1;
if newx < minefield[0].len() {
newx
} else {
pos.0
}
};
l... | true |
02fb638b6d8dc2370880e917a0e1d6f725a62e7a | Rust | ErikUggeldahl/Advent2019 | /day9/src/main.rs | UTF-8 | 897 | 3.078125 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use intcode::Intcode;
fn main() {
let mut file = File::open("input.txt").expect("Could not open input file.");
let mut program = String::new();
file.read_to_string(&mut program).expect("Could not read file to string.");
let program = program
.trim()... | true |
8c3f9b42853dd39c4ce9ad1b49dc964b312550b5 | Rust | Lol3rrr/hc-vault | /src/database/get_credentials.rs | UTF-8 | 1,698 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::Auth;
use crate::Client;
use crate::Error;
use serde::Deserialize;
use std::time::Duration;
#[derive(Deserialize)]
struct DBCreds {
username: String,
password: String,
}
#[allow(dead_code)]
#[derive(Deserialize)]
struct DBCredsResponse {
lease_id: String,
lease_duration: u64,
renewable... | true |
ae32a82fc9bb2a60838704a0bc13cf566fc074e6 | Rust | Kerollmops/Advent-of-Code-2020 | /solutions/day-9/src/main.rs | UTF-8 | 1,787 | 3.484375 | 3 | [] | no_license | use itertools::Itertools;
const INPUT: &str = include_str!("../../../inputs/day-9.txt");
fn main() {
println!("part one answer is: {}", part_one(INPUT, 25));
println!("part two answer is: {}", part_two(INPUT, 25));
}
fn parse_numbers(input: &str) -> Vec<i64> {
input.split_whitespace().map(|s| s.parse().u... | true |
41ff5cdba8f660d24be0f461739f3ac1f52a92fa | Rust | iCodeIN/code | /adventofcode2020/day2_1.rs | UTF-8 | 1,211 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::io::{self, Read};
fn main() -> io::Result<()> {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;
println!("{}", buffer);
let v: Vec<&str> = buffer.split('\n').collect();
let mut valid_count = 0;
for e in v {
let ev: Vec<&str> = e.split(':').collect();
... | true |
d9a34a3ce7f6edf6de4e8785650b279a0d13eb3c | Rust | replicante-io/common | /util/tracing/src/config.rs | UTF-8 | 4,494 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::collections::BTreeMap;
use serde::Deserialize;
use serde::Serialize;
/// Supported tracing backends and their configuration.
#[derive(Clone, Default, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)]
#[serde(tag = "backend", content = "options")]
pub enum Config {
/// The `Noop` tracer (default).
... | true |
750f46f42769fc5484b107a0e341a42f3c3a2688 | Rust | tramulns/zip_password_bruteforcer | /src/main.rs | UTF-8 | 2,566 | 3.03125 | 3 | [] | no_license | use clap::{App, Arg};
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::time::Instant;
fn main() -> Result<(), std::io::Error> {
let matches = App::new("Zip Password Brute Forcer")
.version("0.1.0")
.arg(
Arg::with_name("file")
.short("f")
... | true |
5c377436e43c59c5a51e8c50f5fdab300240416c | Rust | fossabot/krator | /krator/src/manager/tasks.rs | UTF-8 | 7,859 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | //! Defines common `async` tasks used by Krator's Controller
//! [Manager](crate::manager::Manager).
use std::future::Future;
use futures::FutureExt;
use kube::{api::ApiResource, api::GroupVersionKind, Resource};
use kube_runtime::watcher::Event;
use tracing::{debug, info, warn};
use crate::{
manager::controlle... | true |
ce7a221afdd820a6a6905de2caa9361f235f5171 | Rust | rustytools/examples | /streams/src/lib.rs | UTF-8 | 703 | 2.71875 | 3 | [] | no_license |
#[macro_use]
extern crate errloc_macros;
pub struct MySource {
count: u32
}
impl MySource {
pub fn new() -> Self {
return Self { count: 0 }
}
}
impl std::io::Read for MySource {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
if self.count < 42 {
let mut st... | true |
1e7fec08256a07aa1806ddfc0268ecd7b6705808 | Rust | JustinRyanH/Rustlike | /gl/tests/program.rs | UTF-8 | 2,487 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | extern crate glutin;
extern crate rl_gl;
use glutin::GlContext;
use rl_gl::raw::types::*;
#[cfg(test)]
fn headless_gl_window() -> ((), glutin::HeadlessContext) {
let width: i32 = 256;
let height: i32 = 256;
let window = glutin::HeadlessRendererBuilder::new(width as u32, height as u32)
.build()
... | true |
1794d53b899a03174f2b07fe8533825cd81c23f9 | Rust | rocurley/jex | /src/cursor.rs | UTF-8 | 32,723 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::{
jq::jv::{JVArray, JVObject, JVString, OwnedObjectIterator, JV},
lines::{Leaf, LeafContent, LineCursor, UnstyledSpans},
};
use log::trace;
use regex::Regex;
use std::{borrow::Cow, cmp::Ordering, collections::HashSet, fmt, rc::Rc};
use tui::{layout::Rect, text::Spans};
// Requirements:
// * Produce ... | true |
4c73614ad59c9efd619ba24e2fc44781e89553e1 | Rust | tommyshem/learn-to-code | /learn-rustlang/coding-exercises/rust-examples/command_line/environment_variables/src/main.rs | UTF-8 | 258 | 3.421875 | 3 | [] | no_license | use std::env;
fn main() {
let key = "HOME";
// check if the key is set and get value
match env::var(key) {
Ok(val) => println!("Key = {} : value ={:?}", key, val),
Err(e) => println!("couldn't interpret {}: {}", key, e),
}
}
| true |
4ac80ccaff601ebd41ebf24ae6e92c3eb27d51a0 | Rust | vigna/sux-rs | /src/word_array.rs | UTF-8 | 4,621 | 3.1875 | 3 | [
"Apache-2.0",
"LGPL-2.1-only"
] | permissive | use crate::prelude::*;
use anyhow::{Context, Result};
use common_traits::*;
use log::info;
use mmap_rs::{Mmap, MmapMut};
use std::path::Path;
/// A simple wrapper around a slice of bytes interpreted as native-endianess words
/// with utility methods for mmapping.
pub struct WordArray<W: Word, B: AsRef<[u8]>> {
dat... | true |
72ab4038a770042f43c8576db2341fd698354d71 | Rust | sugyan/atcoder | /abc138/src/bin/d.rs | UTF-8 | 841 | 2.65625 | 3 | [] | no_license | use proconio::{fastout, input};
use std::collections::VecDeque;
#[fastout]
fn main() {
input! {
n: usize, q: usize,
ab: [(usize, usize); n - 1],
pq: [(usize, u32); q],
}
let mut graph = vec![Vec::new(); n];
for &(a, b) in &ab {
graph[a - 1].push(b - 1);
graph[b -... | true |
00f5973094b306fb962bfe584ecb16ba1998ba1e | Rust | kvsari/dicey-dice | /src/memorize.rs | UTF-8 | 2,048 | 3.625 | 4 | [
"MIT"
] | permissive | //! Memorization. Not quite memoization because the memory must be passed in.
use std::collections::HashMap;
use std::hash::Hash;
pub fn recall<T, R, F>(
request: T, memory: &mut HashMap<T, R>, calculate: F
) -> R
where T: Clone + PartialEq + Eq + Hash,
R: Clone,
F: Fn(T) -> R,
{
if let Some(r) = m... | true |
e4d03e52d1944576ef65562b854fc539cebb9b4e | Rust | dobrite/game-rs | /src/chunk.rs | UTF-8 | 3,226 | 2.875 | 3 | [] | no_license | use std::collections::HashMap;
use std::cell::Cell;
use renderer::{CubeVertex, VertexBuffer};
use cube::create_cube;
pub const CHUNK_SIZE: uint = 1;
pub const WORLD_HEIGHT: u16 = 256;
pub enum BlockType {
Empty,
Grass,
Dirt,
}
pub struct Block {
block_type: BlockType,
}
pub struct Chunk {
pub b... | true |
e01997c7979027d1bc5caaec98f2890abe7a3a3f | Rust | withoutboats/mock_io | /tests/test.rs | UTF-8 | 2,167 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![feature(const_fn, static_mutex)]
#[macro_use]
extern crate mock_io;
use std::io::{Read, Write};
use std::marker::PhantomData;
use mock_io::{Io, Stdio};
#[test]
fn test_stdin() {
use_mock_stdio!();
mock_stdio::set_stdin(b"YELLOW SUBMARINE");
let mut buf = vec![0; 16];
mock_stdio::stdin().read(&mut... | true |
e88847d1791047e16bd8316aee7cdddc5bfdf5f2 | Rust | reposefulGrass/chip_eight | /src/chip8.rs | UTF-8 | 600 | 2.9375 | 3 | [] | no_license |
use crate::memory::Memory;
use crate::cpu::Cpu;
pub const MAP_ROM_BEGIN: u16 = 0x200;
pub struct Chip8 {
cpu: Cpu,
ram: Memory,
}
impl Chip8 {
pub fn new () -> Chip8 {
Chip8 {
cpu: Cpu::new(),
ram: Memory::new(),
}
}
pub fn load_rom (&mut self, rom: &V... | true |
44d61d897e23d30737426dd8fd847525439d5f49 | Rust | Mirabellensaft/tmp1x2-rs | /src/conversion.rs | UTF-8 | 6,731 | 3.265625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // functions to convert temperature to and from register values
pub fn convert_temp_from_register(msb: u8, lsb: u8) -> f32 {
let mut sign = (u16::from(msb & 0b1000_0000)) << 8;
let extended_mode = (lsb & 1) != 0;
if extended_mode {
if sign != 0 {
sign |= 0b1111_0000 << 8;
}
... | true |
52a78a0412a1031fab3b88f6a1c06277bac68ea3 | Rust | bobmcwhirter/defmt | /decoder/src/frame.rs | UTF-8 | 17,158 | 2.890625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
convert::TryFrom,
fmt::{self, Write as _},
mem,
};
use crate::{Arg, BitflagsKey, Table};
use chrono::TimeZone;
use colored::Colorize;
use defmt_parser::{DisplayHint, Fragment, Level, ParserMode, TimePrecision, Type};
/// A log frame
#[derive(Debug, PartialEq)]
pub struct Frame<'t> {
table: ... | true |
dad3ef5cabea9fcde2c97b62c3bee1381b1392c2 | Rust | 5l1v3r1/cloudman | /src/views/log_view.rs | UTF-8 | 4,895 | 2.65625 | 3 | [
"MIT"
] | permissive | extern crate cursive;
use cursive::{Rect, direction::Direction, view::scroll::{self, Core}};
use cursive::event::{Event, EventResult, Key};
use cursive::vec::Vec2;
use cursive::{Printer, view::View};
cursive::impl_scroller!(LogView::core);
pub struct LogView {
lines: Vec<String>,
core: cursive::view::scroll... | true |
ec5a60f25c3479a6d16f63e47edc61852bed094d | Rust | croaxx/ProjectEuler | /LeetCode/LetterCombinations/solution.rs | UTF-8 | 2,503 | 3.65625 | 4 | [] | no_license | // Problem description: https://leetcode.com/problems/letter-combinations-of-a-phone-number/
// Time complexity: O(const^n), n=len(digits) - generate all combinations
// Space complexity: O(const^n) - store all combinations
use std::{collections::HashMap, iter::FromIterator};
pub struct Solution {}
impl Solution {
... | true |
b19136d695331b49ebe3dbaa783870018ac86a44 | Rust | zrma/1d1rust | /src/boj/p25k/p25192.rs | UTF-8 | 1,633 | 2.953125 | 3 | [] | no_license | use crate::utils::io::read_line;
use std::io::{BufRead, Write};
#[allow(dead_code)]
fn solve25192(reader: &mut impl BufRead, writer: &mut impl Write) {
let n = read_line(reader).parse::<usize>().unwrap();
let mut cnt = 0;
let mut set = std::collections::HashSet::new();
for _ in 0..n {
let s = ... | true |
e1098c2908f87f790c8acbbdc60454fa33ee53a7 | Rust | pebble8888/ellipticcurve | /src/assert_eq_str.rs | UTF-8 | 314 | 2.5625 | 3 | [
"MIT"
] | permissive | #[allow(unused_macros)]
macro_rules! assert_eq_str {
($left:expr, $right:expr) => ({
match (&$left, &$right) {
(left_val, right_val) => {
let left_val_string = left_val.to_string();
assert_eq!(&left_val_string, right_val);
}
}
});
}
| true |
0b3a05c33482f7f0438e8a9a93f3520da9439c01 | Rust | zeroclassic/zeroclassic-vendored-crates | /vendored-sources/crypto_api/src/pbkdf.rs | UTF-8 | 1,612 | 2.9375 | 3 | [
"BSD-2-Clause",
"MIT"
] | permissive | use std::{ error::Error, ops::Range };
/// Information about a PBKDF implementation
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PbkdfInfo {
/// The name
pub name: &'static str,
/// The supported output lengths
pub output_len_r: Range<usize>,
/// The supported password lengths
pub password_len_r: Range<u... | true |
581e492473acfc355e372514e3cff047d01f1205 | Rust | zolbatar/web-rust-scheduler | /src/data/schema.rs | UTF-8 | 1,922 | 2.640625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(PartialEq, Clone, Serialize, Deserialize, Debug)]
pub struct Activity {
pub id: String,
pub lat: f64,
pub lon: f64,
}
#[allow(dead_code)]
impl Activity {
fn new(id: String, lat: f64, lon: f64) -> Activity {
Activity {... | true |
568a81d4e5dc466cf1be934537ece468be3a429e | Rust | jduimovich/rustgc | /src/gc/mod.rs | UTF-8 | 10,350 | 2.59375 | 3 | [] | no_license | use std::mem;
use std::time::SystemTime;
#[cfg(feature="dynamic_mem")]
const MAX_MEMORY_SLOTS: usize = 1024 * 1024 * 2;
#[cfg(not(feature="dynamic_mem"))]
const MAX_MEMORY_SLOTS: usize = 1024 * 128;
type Bits = u128;
const MARK_BITS_PER_SLOT: usize = mem::size_of::<Bits>();
const MARK_BITS: usize = MAX_MEMORY_SLO... | true |
fb585bb8bbe9a1b42a7188c659f8fe77b7150093 | Rust | vadixidav/machine-vision-formats | /src/pixel_format.rs | UTF-8 | 7,851 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Implementations of specific pixel formats.
//
// TODO: Check if we should use [PFNC (Pixel Format Naming
// Convention)](https://www.emva.org/wp-content/uploads/GenICamPixelFormatValues.pdf)
// names.
// TODO: Check if names from ffmpeg (e.g. `AV_PIX_FMT_YUVA444P`) would be
// better.
// Also note the formats at... | true |
f5f0e48344b10c1890c34522a499c5394d9fc062 | Rust | ryanfowler/lines | /src/cli.rs | UTF-8 | 4,191 | 2.671875 | 3 | [
"MIT"
] | permissive | // The MIT License (MIT)
//
// Copyright (c) 2022 Ryan Fowler
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// copies of t... | true |
403514ae8025493783f4a9ac9ff0ced94e2e076f | Rust | qiongtubao/search_index_test | /src/query/cat_query.rs | UTF-8 | 14,072 | 2.546875 | 3 | [] | no_license | use tantivy::query::{Query, Weight, Scorer, Explanation, BooleanQuery, RangeQuery, BooleanWeight, BitSetDocSet, Intersection, ConstScorer, TermScorer, VecDocSet};
use tantivy::{Searcher, TantivyError, SegmentReader, DocSet, Term, InvertedIndexReader, DocId, SkipResult, BitSet};
use tantivy::schema::{Field, IndexRecordO... | true |
91ce448b0f9de05e8cbc8b2ec7a9cb7676bededb | Rust | gnoliyil/fuchsia | /src/sys/lib/fidl-fuchsia-pkg-ext/src/fidl_iterator_to_stream.rs | UTF-8 | 5,568 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
fidl_fuchsia_pkg as fpkg,
futures::{future::TryFutureExt as _, stream::Stream},
};
/// Converts a proxy to a FIDL iterator like:
///
/// pro... | true |
8ce3fe1f4e8578ea5e7c632414e1f226b8b44e11 | Rust | sbnair/toy-rust-ipfs | /src/config.rs | UTF-8 | 1,703 | 2.640625 | 3 | [] | no_license | use crypto;
use util;
use rustc_serialize::Decodable;
use rustc_serialize::base64::{self, ToBase64};
use rustc_serialize::json::{self, Json};
use rust_multihash::Multihash;
use std::io::Read;
use std::path::PathBuf;
pub const DEFAULT_REPO_ROOT: &'static str = "~/";
pub const DEFAULT_REPO_PATH: &'static str = ".rust-i... | true |
d558092d70d87ffa3719386025e1289889dbe541 | Rust | a-kenji/relm4 | /relm4-macros/src/funcs.rs | UTF-8 | 3,001 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::{spanned::Spanned, Error, ImplItemMethod, Result};
pub(super) struct Funcs {
pub pre_init: Option<TokenStream2>,
pub post_init: Option<TokenStream2>,
pub pre_connect_components: Option<TokenStream2>,
pub post_connect_components: O... | true |
475d1dd165de28a9e99fa2357018ec6a61c2eb15 | Rust | dsnam/LocustDB | /src/engine/vector_op/nonzero_indices.rs | UTF-8 | 1,570 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use std::marker::PhantomData;
use engine::typed_vec::AnyVec;
use engine::vector_op::*;
use engine::*;
#[derive(Debug)]
pub struct NonzeroIndices<T, U> {
input: BufferRef,
output: BufferRef,
t: PhantomData<T>,
u: PhantomData<U>,
}
impl<T: GenericIntVec<T> + IntoUsize, U: GenericIntVec<U>> NonzeroIndi... | true |
51d8a6d2e4d7aa8627e9305148f8c6376b28884b | Rust | bytecodealliance/wasmtime | /crates/fuzzing/src/generators/module.rs | UTF-8 | 2,461 | 3.015625 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | //! Generate a Wasm module and the configuration for generating it.
use arbitrary::{Arbitrary, Unstructured};
use wasm_smith::SwarmConfig;
/// Default module-level configuration for fuzzing Wasmtime.
///
/// Internally this uses `wasm-smith`'s own `SwarmConfig` but we further refine
/// the defaults here as well.
#[d... | true |
4e8281513614f05c03b919b01ee7782a5cdb7f56 | Rust | denzp/rust-crate-compile-test | /src/cargo_messages.rs | UTF-8 | 2,020 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use steps::check_errors::{CompilerMessage, MessageLocation, MessageType};
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum DiagnosticLevel {
Error,
Warning,
Note,
Help,
#[serde(rename = "")]
Empty,
}
#[derive(Debug, Deseriali... | true |
a96a0131c60eea56df1d546308850064e60d2371 | Rust | mich101mich/aoc-2017 | /src/days/day_03.rs | UTF-8 | 1,632 | 2.921875 | 3 | [] | no_license | use crate::utils::*;
#[allow(unused)]
pub fn run() {
#[allow(unused_variables)]
let input = include_str!("../input/03.txt");
// let input = r#"1024"#;
let num = parse(input);
let mut values: HashMap<(isize, isize), isize> = HashMap::new();
values.insert((0, 0), 1);
values.insert((1, 0), 1... | true |
b8f39dc8c3961af0519e06b651ca3dde95ff5546 | Rust | hgzimmerman/rust_sms | /src/models/users/mod.rs | UTF-8 | 1,230 | 2.609375 | 3 | [] | no_license | mod user_state;
mod realized_user;
pub use self::user_state::UserState;
pub use self::realized_user::RealizedUser;
use schema::users;
use diesel::pg::PgConnection;
use diesel;
use diesel::prelude::*;
/// Db interfaceable user
#[derive(Queryable, Identifiable, Clone, Debug, AsChangeset)]
pub struct User {
pub id: ... | true |
c791fa8f0210c1fa415f6056bdcf43ce327b00dc | Rust | daniel-e/rustml | /src/features.rs | UTF-8 | 567 | 2.8125 | 3 | [] | no_license | use math::{Mean, Var};
use math::{Dimension, Normalization};
/// Trait to estimate the mean and the variance of a set of samples.
pub trait Scale<T> {
fn scale(&self, nrm: Normalization) -> T;
}
impl Scale<Matrix<f32>> for Matrix<f32> {
fn scale(&self, nrm: Normalization) -> Matrix<f32> {
let mean_... | true |
42f45175449ee7df7645a45db999e3adbc7c9cd7 | Rust | parallaxsecond/rust-tss-esapi | /tss-esapi/src/structures/lists/tagged_tpm_property.rs | UTF-8 | 3,865 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
use crate::{
constants::PropertyTag,
structures::TaggedProperty,
tss2_esys::{TPML_TAGGED_TPM_PROPERTY, TPMS_TAGGED_PROPERTY},
Error, Result, WrapperErrorKind,
};
use log::error;
use std::{convert::TryFrom, iter... | true |
246c11bee28f1fffa7046beb97abd954518c6e5d | Rust | shadyproject/learn | /rust/gentle_introduction/fun1.rs | UTF-8 | 834 | 4.09375 | 4 | [
"MIT"
] | permissive | fn sqr(x: f64) -> f64 {
x * x
}
//absolute value
fn abs(x: f64) -> f64 {
if x > 0.0 {
x
} else {
-x
}
}
//ensure a number always falls in the given range
fn clamp(x: f64, x1: f64, x2: f64) -> f64 {
if x < x1 {
x1
} else if x > x2 {
x2
} else {
x
... | true |
a1f2d4133ec0f8f9e2c9a484dc5f43bb657af01a | Rust | ivanhrabcak/shopping-list-rust | /src/repositories/user.rs | UTF-8 | 3,599 | 2.828125 | 3 | [] | no_license | #![allow(proc_macro_derive_resolution_fallback)]
use diesel::prelude::*;
use diesel::dsl::*;
use crate::models;
use crate::repositories::schema::users;
use crate::repositories::schema::users::dsl::*;
use crate::request::Credentials;
use crypto::sha2::Sha512;
use crypto::digest::Digest;
use std::convert::TryFrom;
... | true |
026d5084f6a2f3ed0b6b2e540f6b0c52e3fe909e | Rust | r-asou/databend | /common/datavalues/src/types/data_type_coercion.rs | UTF-8 | 15,279 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Datafuse Labs.
//
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... | true |
7b42446cf85dca87009c65a120cc8eca5a8c13f7 | Rust | public/googapis | /googapis/genproto/google.cloud.secretmanager.v1.rs | UTF-8 | 71,516 | 3.09375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /// A [Secret][google.cloud.secretmanager.v1.Secret] is a logical secret whose value and versions can
/// be accessed.
///
/// A [Secret][google.cloud.secretmanager.v1.Secret] is made up of zero or more [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] that
/// represent the secret data.
#[derive(Clone, Par... | true |
4e2e9a185dcbffb6f7537744ee728bdc665427dc | Rust | modernserf/aoc-2017 | /day-2/src/main.rs | UTF-8 | 1,352 | 3.3125 | 3 | [] | no_license | use std::cmp;
fn main() {
let tsv = include_str!("input.txt");
let data = parse_tsv(tsv);
let sum = data.iter()
.map(|row| row_checksum(row))
.sum::<u32>();
println!("part 1: {}", sum);
let div_sum = data.iter()
.map(|row| divisible_row_checksum(row))
.sum::<u32>(... | true |
1c8821498124555708c9568fc32792bed164a26f | Rust | storance/krpc-bindings-rs | /src/spacecenter/parts/engine.rs | UTF-8 | 14,598 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use super::Part;
use crate::codec::{Decode, Encode};
use crate::spacecenter::Thruster;
use crate::{remote_type, RemoteObject, Vector3};
use std::collections::BTreeMap;
remote_type!(
/// An engine, including ones of various types. For example liquid fuelled gimballed engines,
/// solid rocket boosters and jet engines.... | true |
037a3304727026437e70d0a1a720f2a0db2208ec | Rust | comp590-19s/starter-ps06-thegrep-nfa | /nfa.rs | UTF-8 | 3,893 | 3.390625 | 3 | [] | no_license | pub mod helpers;
// Starter code for PS06 - thegrep
// Add Honor Code Header and Collaborators Here
use super::parser::Parser;
use super::parser::AST;
use super::tokenizer::Tokenizer;
use self::State::*;
/**
* ===== Public API =====
*/
/**
* An NFA is represented by an arena Vec of States
* and a start state.
... | true |
cd0c493ce3e1417f8acd8747d538ef738dc04f3f | Rust | mikialex/rainray | /src/bvh.rs | UTF-8 | 4,161 | 3.15625 | 3 | [] | no_license | use crate::math::*;
#[derive(Debug, Clone)]
pub enum SplitMethod {
SAH,
Middle,
EqualCounts,
}
pub enum Axis {
x,
y,
z,
}
pub struct BVHNode {
pub bounding_box: Box3,
pub left: Option<Box<BVHNode>>,
pub right: Option<Box<BVHNode>>,
pub split_axis: Option<Axis>,
pub primiti... | true |
35d66a900fc7e6b94158d7ad76a87fe14876a5f0 | Rust | CodeSandwich/BrainRust | /src/memory.rs | UTF-8 | 725 | 2.984375 | 3 | [
"MIT"
] | permissive | use MemoryCellEditor;
pub struct Memory<T> {
positive_range: Vec<T>,
negative_range: Vec<T>,
}
impl<T> Memory<T> {
pub fn new() -> Memory<T> {
Memory {
positive_range: vec![],
negative_range: vec![],
}
}
pub fn get<U: MemoryCellEditor<T>>(&mut self, index: ... | true |
6a917752b01cda3f0d768156e4ec9ef0facbc276 | Rust | justin1dennison/gribbrs | /src/sections/grid_definition.rs | UTF-8 | 2,328 | 2.84375 | 3 | [] | no_license | use crate::tables::{InterpretationOfNumbersAtEndOfSection3, SourceOfGridDefinition};
use byteorder::{BigEndian, ReadBytesExt};
use serde::{Deserialize, Serialize};
use std::io::{Read, Seek};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct GridDefinition {
pub length: u32,
pub number_of_section: ... | true |
ff7d83802ace74f8117eb24e05fb944a1f83dafd | Rust | luteberget/junction | /lib/route_finder/src/routes.rs | UTF-8 | 11,930 | 2.625 | 3 | [] | no_license | use rolling::input::staticinfrastructure::*;
use std::collections::{HashSet, BTreeSet};
use smallvec::SmallVec;
#[derive(Debug)]
pub enum ConvertRouteIssue {
NoBoundaries,
StateConversionFailed( RouteEntryExit, RouteEntryExit),
ExitedUnenteredSection( RouteEntryExit, ObjectId),
RouteTooShort(RouteEntry... | true |
ee256dd957654adbd115c3e26651db94002b8840 | Rust | snoyberg/terra-rust | /terra-rust-api/src/messages/bank.rs | UTF-8 | 995 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | //use crate::client::client_types::terra_u64_format;
use crate::core_types::{Coin, MsgInternal};
use crate::messages::Message;
use serde::Serialize;
#[derive(Serialize, Debug)]
/// Message: Send N coins from an address to another
pub struct MsgSend {
pub amount: Vec<Coin>,
pub from_address: String,
pub t... | true |
ccd71c9ee331979e7f1583cbca98ab2a7ba9aa7d | Rust | aclysma/dxmath | /src/math.rs | UTF-8 | 2,332 | 2.78125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::arch::x86_64::*;
#[derive(Debug)]
pub struct Float2(pub [f32;2]);
impl Float2 {
fn x(&self) -> f32 { self.0[0] }
fn y(&self) -> f32 { self.0[1] }
fn x_mut(&mut self) -> &mut f32 { &mut self.0[0] }
fn y_mut(&mut self) -> &mut f32 { &mut self.0[1] }
}
#[derive(Debug)]
pub struct Float3(pub [f... | true |
ddb94e0ad895718973daf569f1b7fbf40bc1267d | Rust | jonmsawyer/uva-online-judge | /Problem Set Volumes (100...1999)/Volume 1 (100-199)/103 - Stacking Boxes/rust/src/boxes.rs | UTF-8 | 4,244 | 3.5 | 4 | [
"MIT"
] | permissive | //! `rust` crate.
//!
//! Author: Jonathan Sawyer <jonmsawyer[at]gmail.com>
//!
//! Date: 2020-06-19
//!
//! This crate implements one solution to the [Stacking Boxes problem],
//! which calculates the longest string of stacking boxes.
//!
//! [Stacking Boxes problem]: https://onlinejudge.org/index.php?option=com_onlin... | true |
49f22ab6570849843158f9b0b3f23808d947c9f6 | Rust | DarthStrom/rust-ray-tracer-challenge | /src/patterns/gradient.rs | UTF-8 | 2,038 | 3.484375 | 3 | [] | no_license | use std::any::Any;
use crate::{
color::{self, Color},
transformations::Transform,
tuple::Tuple,
};
use super::{BoxPattern, Pattern, PatternBuilder};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Gradient {
pub a: Color,
pub b: Color,
pub transform: Transform,
}
impl Gradient {
pub ... | true |
d813e0a437a31d79aa3380946cf17c8f9afff6c1 | Rust | Michael-F-Bryan/ffi_helpers | /src/error_handling.rs | UTF-8 | 9,789 | 3.671875 | 4 | [
"MIT"
] | permissive | //! Common error handling routines.
//!
//! The main error handling method employed is a thread-local variable called
//! `LAST_ERROR` which holds the most recent error as well as some convenience
//! functions for getting/clearing this variable.
//!
//! The theory is if a function fails then it should return an *"obvi... | true |
2c809e6c2356d6efdea581ad37285c720f721aec | Rust | ian-wazowski/FIXEngine-rs | /src/messages/mod.rs | UTF-8 | 5,029 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive |
use fields::{FIXMessageField, FIXMessageFields};
use std::any::Any;
use std::collections::HashMap;
pub trait FIXMessage : FIXMessageFields {}
pub struct RawFIXMessage {
field_values : Vec<Box<Any>>,
field_indices : HashMap<u32, Vec<usize>>
}
impl FIXMessageFields for RawFIXMessage {
fn get_value<T : An... | true |
d1e78bf7f6379f0c53ff2abcd58f7d9480f87feb | Rust | Wattyyy/LeetCode | /submissions/rotting-oranges/solution.rs | UTF-8 | 1,499 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::cmp::max;
use std::collections::VecDeque;
impl Solution {
pub fn oranges_rotting(grid: Vec<Vec<i32>>) -> i32 {
let row_len = grid.len();
let col_len = grid[0].len();
let mut queue: VecDeque<(usize, usize, i32)> = VecDeque::new();
let mut rotten = grid.clone();
for r... | true |
a4074b1b575cc74c54b6765e212d8ad39e486775 | Rust | JP-Ellis/coding-problems | /src/daily_coding_problem/p051.rs | UTF-8 | 1,712 | 3.234375 | 3 | [] | no_license | use crate::{Error, Problem};
use rand::prelude::*;
use std::io::prelude::*;
pub struct P;
const STATEMENT: &str = r#"Given a function that generates perfectly random
numbers between 1 and k (inclusive), where k is an input, write a function that
shuffles a deck of cards represented as an array using only swaps.
It s... | true |
bad5a3f19f294071e3cf88e28ea4af879efda65c | Rust | FFY00/delsum | /delsum-lib/src/lib.rs | UTF-8 | 10,627 | 3.09375 | 3 | [
"MIT"
] | permissive | mod bitnum;
pub mod checksum;
pub(crate) mod factor;
mod keyval;
use bitnum::BitNum;
use checksum::{
crc::{CRCBuilder, CRC},
fletcher::{Fletcher, FletcherBuilder},
modsum::{ModSum, ModSumBuilder},
Digest, LinearCheck, RangePairs, Relativity, SumStr,
};
use checksum::{CheckBuilderErr, CheckReverserError}... | true |
a7082a4db46b7d73fc175be7920e266698ec6840 | Rust | LukeMathWalker/advent-of-code-2019 | /day02/src/main.rs | UTF-8 | 3,418 | 3.5 | 4 | [] | no_license | use itertools::iproduct;
use std::str::FromStr;
fn read_input(path: &str) -> Result<Vec<usize>, anyhow::Error> {
let input = std::fs::read_to_string(path)?;
let instructions = input
.trim()
.split(",")
.map(|s| usize::from_str(&s).expect("Failed to parse instruction"))
.collect(... | true |
fa5ece3506d734d885cf0062f5f302bcf8c68837 | Rust | swc-project/swc | /crates/dbg-swc/src/es/minifier/ensure_size.rs | UTF-8 | 8,135 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::{
path::{Path, PathBuf},
sync::Arc,
};
use anyhow::{Context, Result};
use clap::Args;
use rayon::prelude::*;
use swc_common::{
errors::{ColorConfig, Handler, HANDLER},
SourceFile, SourceMap, GLOBALS,
};
use tracing::info;
use crate::util::{
all_js_files, gzipped_size,
minifier::{get_e... | true |
c493d0c4ef24eb681d823e2a815b39cb366be6e3 | Rust | johnstonskj/rust-financial | /fin_model/src/symbol.rs | UTF-8 | 2,756 | 3.71875 | 4 | [
"MIT"
] | permissive | /*!
Provides types and functions for market symbols.
In general the `Symbol` type is loosely defined, it is stored as a `String`
but there is little standardization across markets and geographies
concerning length or character set. To this end the function `is_valid`
simply takes the commonly known limits and returns ... | true |
ae363734627b27a3ddb15b5951b51fde10ce12e3 | Rust | mackenziestarr/opl3 | /src/uart.rs | UTF-8 | 1,965 | 2.8125 | 3 | [] | no_license | use volatile::Volatile;
use bit_field::BitField;
use core;
use super::port::{Rx,Tx};
#[repr(C,packed)]
pub struct Uart {
bdh : Volatile<u8>,
bdl : Volatile<u8>,
c1 : Volatile<u8>,
c2 : Volatile<u8>,
s1 : Volatile<u8>,
s2 : Volatile<u8>,
c3 : Volatile<u8>,
d : Vo... | true |
e7286f22d2e0c65d48e3a13079dbfc53c034e539 | Rust | femnad/gel | /src/main.rs | UTF-8 | 7,115 | 2.5625 | 3 | [] | no_license | extern crate clap;
extern crate reqwest;
extern crate roxmltree;
extern crate select;
extern crate scraper;
#[macro_use]
extern crate tantivy;
use std::path::Path;
use std::process::Command;
use clap::{App, Arg, SubCommand, AppSettings};
use reqwest::StatusCode;
use roxmltree::Document;
use tantivy::schema::Schema;
us... | true |
e3f25407d8e8760dfef35a1c849a4cee21374acb | Rust | mcountryman/wuffs-rs | /wuffs/src/std/compression/gzip.rs | UTF-8 | 2,854 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{
boxed::{WuffsBox, WuffsBoxed},
buf::WuffsBuf,
slice::WuffsSlice,
status::{IntoResult, WuffsError},
};
use wuffs_sys::{
sizeof__wuffs_gzip__decoder, wuffs_gzip__decoder, wuffs_gzip__decoder__initialize,
wuffs_gzip__decoder__set_quirk_enabled, wuffs_gzip__decoder__transform_io,
WUFFS_GZIP__DECO... | true |
20c04be27d8c3e00b0938815d613299a0571297b | Rust | coreos/afterburn | /src/providers/microsoft/goalstate.rs | UTF-8 | 3,434 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | //! Logic to interact with WireServer `goalstate` endpoint.
use anyhow::{anyhow, Result};
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
pub(crate) struct GoalState {
#[serde(rename = "Container")]
pub container: Container,
#[serde(rename = "Incarnation")]
incarnation: String,
}
impl Go... | true |
df14e52f06a4ac993590b4ec7f019402b6b00eff | Rust | sourcedennis/wasm-pathtracer | /src/math/vec3.rs | UTF-8 | 4,458 | 3.765625 | 4 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | use std::ops;
use std::fmt;
/// A vector in 3-dimensional space
#[derive(Copy,Clone)]
pub struct Vec3 {
pub x : f32,
pub y : f32,
pub z : f32
}
impl Vec3 {
/// The vector that lies at the origin, which has 0 length; (0,0,0)
pub const ZERO: Vec3 = Vec3 { x: 0.0, y: 0.0, z: 0.0 };
/// Constructs a new vect... | true |
afea4e02014fbb88ed551719dc76f3cb120a919a | Rust | ZhouHansen/async_rust_playground | /src/event_loop.rs | UTF-8 | 2,456 | 3.171875 | 3 | [] | no_license | use std::collections::BTreeMap;
use std::sync::mpsc;
use std::thread;
use std::time::Instant;
use super::task_exc::*;
/// A handle to a timer, used for registering wakeups
#[derive(Clone)]
pub struct ToyTimer {
pub tx: mpsc::Sender<Registration>,
}
/// A wakeup request
pub struct Registration {
pub at: Instan... | true |
daebc0b861c1d64722ff97d6b0d28221d3f09827 | Rust | feather-rs/feather | /feather/plugin-host/src/context.rs | UTF-8 | 13,622 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use std::{
alloc::Layout,
cell::{Ref, RefMut},
marker::PhantomData,
mem::size_of,
panic::AssertUnwindSafe,
ptr::NonNull,
sync::atomic::{AtomicBool, Ordering},
};
use anyhow::anyhow;
use bytemuck::{Pod, Zeroable};
use feather_common::Game;
use feather_ecs::EntityBuilder;
use quill_common::Co... | true |
7ed796b533e30a6b2055ed1247984273528e8525 | Rust | neunenak/hilite | /src/main.rs | UTF-8 | 3,549 | 3.0625 | 3 | [] | no_license | /* hilite - runs a command, highlighting everything it sends to stderr
* based on hilite by Mike Schiraldi <mgs21@columbia.edu>
*
*/
extern crate getopts;
use std::env;
use std::io;
use std::io::Write;
use std::io::Read;
use std::process;
macro_rules! print_stderr {
($($arg:tt)*) => {
(write!(&mut io:... | true |
de54e3ec4359041b202836ac07319e207897336b | Rust | marosluuce/rchip8 | /src/ops/jump_absolute.rs | UTF-8 | 822 | 3.296875 | 3 | [] | no_license | use cpu::Cpu;
use ops::op::{Matcher, Op};
use std::fmt;
pub struct JumpAbsolute {
address: u16,
}
impl Op for JumpAbsolute {
fn execute(&self, cpu: Cpu) -> Cpu {
Cpu {
pc: self.address,
..cpu
}
}
}
impl Matcher for JumpAbsolute {
const MASK: u16 = 0x1FFF;
... | true |
e1274765b3ed02ff4225f16e8e0c87d5113a4929 | Rust | mswdwk/bincode | /tests/issues/issue_431.rs | UTF-8 | 791 | 2.6875 | 3 | [
"MIT"
] | permissive | #![cfg(all(feature = "std", feature = "derive"))]
extern crate std;
use bincode::{Decode, Encode};
use std::borrow::Cow;
use std::string::String;
#[derive(Encode, Decode, PartialEq, Debug)]
struct T<'a, A: Clone + Encode + Decode> {
t: Cow<'a, U<'a, A>>,
}
#[derive(Clone, Encode, Decode, PartialEq, Debug)]
stru... | true |
db850f043e04b0c317d58045ab8528cfbd3e7630 | Rust | anholt/glsl | /src/lib.rs | UTF-8 | 816 | 2.84375 | 3 | [] | no_license | //! # GLSL compiler
//!
//! This crate is a GLSL450 compiler. It’s able to parse valid GLSL450 formatted source into an
//! abstract syntax tree (AST). That AST can then be transformed into SPIR-V, your own format or
//! even folded back to a raw GLSL `String` (think of a minifier, for instance).
//!
//! You’ll find tw... | true |
59cf03ee6cb0a52282c20b39aa3df6ea5faf51ed | Rust | szabgab/slides | /rust/examples/vectors/map2.rs | UTF-8 | 209 | 2.84375 | 3 | [] | no_license | fn main() {
let chars = vec!['a', 'b', 'c'];
let mut c = 0;
let pairs = chars.into_iter().rev().map(|letter| { c += 1; (letter, c) });
for pair in pairs {
println!("{pair:?}");
}
}
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.