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
45b64e681b5a39235cf80bb655cf8de0f7663fbe
Rust
lazear/types-and-programming-languages
/04_stlc/src/typing.rs
UTF-8
9,307
3.296875
3
[ "MIT" ]
permissive
use crate::term::Term; use std::fmt; #[derive(Clone, PartialEq, PartialOrd)] pub enum Type { Unit, Bool, Nat, Arrow(Box<Type>, Box<Type>), Record(Record), } #[derive(Clone, PartialEq, PartialOrd)] pub struct Record { // pub span: Span, pub ident: String, pub fields: Vec<RecordField>, }...
true
b5047b3f08823fdd277912302ba06660e59b188e
Rust
nao-kobayashi/PrjEuler
/problem82/src/main.rs
UTF-8
2,325
3.265625
3
[]
no_license
use std::cmp::min; //p082_matrix.txt fn get_data() -> Vec<Vec<i32>> { let text_contents = std::fs::read_to_string("./p082_matrix.txt").unwrap(); let all_lines = text_contents.split("\n"); let mut data = Vec::new(); for line in all_lines { if line != "" { let line_vec = line.split(",...
true
4db1ba43d9a898ebf6d3e54296e5754d94c561f2
Rust
nikomatsakis/salsa
/components/salsa-entity-mock/src/function/accumulated.rs
UTF-8
2,171
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{ hash::FxHashSet, key::DependencyIndex, runtime::local_state::QueryInputs, storage::{HasJar, HasJarsDyn}, Database, DatabaseKeyIndex, }; use super::{Configuration, DynDb, FunctionIngredient}; use crate::accumulator::Accumulator; impl<C> FunctionIngredient<C> where C: Configuration,...
true
18eff8b4ffa96cd7cd544516956cdbe850f16842
Rust
zoosky/prisma-engine
/migration-engine/core/src/migration/datamodel_differ.rs
UTF-8
15,053
2.546875
3
[ "Apache-2.0" ]
permissive
#![deny(rust_2018_idioms)] mod directives; mod enums; mod fields; mod models; mod top_level; use directives::DirectiveDiffer; use enums::EnumDiffer; use fields::FieldDiffer; use models::ModelDiffer; use top_level::TopDiffer; use datamodel::ast; use migration_connector::steps::{self, MigrationStep}; /// Diff two dat...
true
04ba4b204b5f7705c4236910b1114175b3f5a6cd
Rust
tommymalmqvist/timereport-slack-rust
/slack/src/main.rs
UTF-8
5,337
2.53125
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_slog; #[macro_use] extern crate slog; #[macro_use] extern crate sloggers; #[macro_use] extern crate failure; #[macro_use] extern crate failure_derive; use failure::{bail, Error}; use serde::{Deserialize...
true
5e57b5022606c01ad72fa6c7697c48b7f2e186bb
Rust
azriel91/autexousious
/crate/workspace_tests/src/game_play/system/game_play_removal_augment_system.rs
UTF-8
2,931
2.671875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
#[cfg(test)] mod tests { use std::{any, str::FromStr}; use amethyst::{ ecs::{Builder, Entity, Read, SystemData, World, WorldExt}, shrev::EventChannel, Error, }; use amethyst_test::AmethystApplication; use asset_model::{config::AssetSlug, loaded::AssetIdMappings}; use gam...
true
5da64cdf050151f101c735e86eccc6f38c8f734f
Rust
str4d/rage
/age/src/ssh.rs
UTF-8
20,764
2.53125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! The "ssh-rsa" and "ssh-ed25519" recipient types, which allow reusing existing SSH keys //! for encryption with age-encryption.org/v1. //! //! These recipient types should only be used for compatibility with existing keys, and //! native X25519 keys should be preferred otherwise. //! //! Note that these recipient ty...
true
632a6f1aee18c87438a2d1277b01e1cb1718bb39
Rust
gnoliyil/fuchsia
/src/connectivity/lib/at-commands/codegen/src/main.rs
UTF-8
3,109
2.65625
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2020 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 { anyhow::{Context, Result}, codegen_lib::{codegen, definition, parser}, log::info, simplelog::{Config as LogConfig, LevelFilter, Simpl...
true
3803e03d059b50642c7460a5fc39a2f16e5be4f0
Rust
octavonce/signature-schemes
/src/bls/aggr_fast.rs
UTF-8
6,478
2.578125
3
[ "Apache-2.0" ]
permissive
extern crate amcl; use super::amcl_utils::{hash_on_GroupG1, ate_pairing}; use super::types::{GroupG1, GroupG2}; use super::constants::{CURVE_ORDER, GeneratorG2, GroupG2_SIZE}; use super::common::{SigKey, VerKey, Keypair}; use super::simple::Signature; use bls::amcl_utils::get_G2_point_from_bytes; use bls::amcl_utils::...
true
1a4db1fbf7fea3546078429dba0a02b11dfb3e6e
Rust
sognefej/gl-matrix
/src/mat2d.rs
UTF-8
20,492
3.734375
4
[ "MIT" ]
permissive
//! 2x3 Matrix //! //! A mat2d contains six elements defined as: //! ``` //! use gl_matrix::common::*; //! //! let a: f32 = 0.; //! let b: f32 = 0.; //! let c: f32 = 0.; //! let d: f32 = 0.; //! let tx: f32 = 0.; //! let ty: f32 = 0.; //! //! let mat: Mat2d = [a, b, c, //! d, tx, ty]; //! ``` //...
true
792be559361150f0565fc02e2c339999641e85f9
Rust
9999years/rnix-eval
/src/pos.rs
UTF-8
1,837
2.96875
3
[]
no_license
use std::borrow::{Borrow, ToOwned}; use std::fmt; use std::fmt::{Display, Formatter}; use crate::symbol_table::Symbol; #[derive(Debug, PartialEq)] pub struct KnownPos<'arena> { pub file: Symbol<'arena>, pub line: usize, pub column: usize, } impl Display for KnownPos<'_> { fn fmt(&self, f: &mut Format...
true
a41728419c959ed130f31699b5a02450e892f214
Rust
kayw/CareerInterview
/july100_30_digit1s_of_n/count_digit_of_1s.rs
UTF-8
1,169
3.515625
4
[]
no_license
fn get_count_of_digit1s(n: isize ) -> isize { let mut prefix = [0; 10]; let mut suffix: [isize; 10] = [0; 10]; let mut digit = [0; 10]; let mut i = 0; let mut base = 1; let mut count = 0; while base < n { suffix[i] = n % base; digit[i] = ((n % (base * 10)) - suffix[i]) / base; ...
true
de11cc17c065dd5e8b67562266d242e84e261f9f
Rust
gohanman/AdventOfCode2017
/day18/src/main.rs
UTF-8
7,325
3.234375
3
[ "Apache-2.0" ]
permissive
#[derive(Clone, Debug)] enum Operand { Value(i64), Register(char), } #[derive(Clone, Debug)] enum ISA { Play(char), Recover(char), Send(char), Recv(char), Set(char, Operand), Add(char, Operand), Mul(char, Operand), Mod(char, Operand), JumpGZ(Operand, Operand), Invalid, ...
true
ab45ad182d385d4d9c4758ed782821e6d327b196
Rust
aQaTL/kod_jam
/src/components.rs
UTF-8
929
2.71875
3
[]
no_license
use bevy::prelude::*; pub const TILE_SIZE: f32 = 32.0; pub struct Textures { pub player_texture: Handle<ColorMaterial>, pub ground_tile: Handle<ColorMaterial>, pub transparent_ground_tile: Handle<ColorMaterial>, pub portal_texture: Handle<ColorMaterial>, pub spikes_texture: Handle<ColorMaterial>, pub missile_te...
true
50c9aa02902f3116437def0b2229582de5ec466b
Rust
adamrodger/advent-2016-rs
/src/day24.rs
UTF-8
5,262
3
3
[ "MIT" ]
permissive
use crate::{compass::Point, Part}; use aoc_runner_derive::{aoc, aoc_generator}; use itertools::Itertools; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use std::collections::{HashMap, HashSet, VecDeque}; #[derive(Debug)] pub struct Game { graph: HashMap<Point, Vec<Point>>, targets: HashSet<Poin...
true
ca443234e56122a2978fa2a5b610d796ae77adc8
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-11319.rs
UTF-8
431
2.9375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn main() { match Some(10) { //~^ NOTE `match` arms have incompatible types Some(5) => false, //~^ NOTE this is found to be of type `bool` Some(2) => true, //~^ NOTE this is found to be of type `bool` None => (), //~^ ERROR match arms have incompatible types ...
true
882cd4f4d9a2b0f4e14ffb23efad892c6f9a1f9c
Rust
rgrunbla/AOC
/2020/18/rust/second/src/main.rs
UTF-8
2,089
3.078125
3
[]
no_license
extern crate nom; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path>, { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) } use nom::{ branch::alt, bytes::complete:...
true
3905463cc9a5b16ed4ecad1da377aa16b703397b
Rust
tillrohrmann/rust-challenges
/euler-68/src/lib.rs
UTF-8
4,512
3.671875
4
[ "Apache-2.0" ]
permissive
pub struct Permutate<'a, T: 'a> { input: &'a Vec<T>, counter: usize, number_permutations: usize, } fn factorial(v: usize) -> usize { (1..=v).fold(1, |result, value| result * value) } impl<'a, T> Permutate<'a, T> { pub fn new(input: &'a Vec<T>) -> Permutate<'a, T> { let number_permutations ...
true
df98ad6d9467879d1901dd912826bad2ced57d2b
Rust
uauramenezes/Algorithms
/src/search/binary_search.rs
UTF-8
1,948
4.125
4
[]
no_license
use std::cmp::Ordering; pub fn binary_search<T: Ord>(items: &[T], element: T) -> Option<usize> { let mut start = 0; let mut end = items.len(); while start < end { let middle = (end - start) / 2 + start; // Another solution using pattern matching found on the internet // https://th...
true
f21a61c29d5c3e0e95453c21a467d9d0cb03c01d
Rust
isgasho/em-refactor
/em-refactor-examples/extract_method/example_1_after.rs
UTF-8
105
2.71875
3
[ "Apache-2.0" ]
permissive
fn main() { let i = ({ foo})(); print!("{}", i); } fn foo() -> i32 {let mut i = 0; i += 1;i}
true
9c37becf8e02c052c58fa05111e99e1472455781
Rust
carrotflakes/kantera
/src/render.rs
UTF-8
3,544
3
3
[ "MIT" ]
permissive
use crate::pixel::Rgba; use crate::util::hsl_to_rgb; pub type Res = (usize, usize); #[derive(Debug)] pub struct RenderOpt { pub x_range: std::ops::Range<i32>, pub y_range: std::ops::Range<i32>, pub res_x: usize, pub res_y: usize, pub frame_range: std::ops::Range<i32>, pub framerate: usize, } ...
true
a3d048eb10a022a73c37cec5594070b08508329a
Rust
schell/todo_finder
/todo_finder/src/main.rs
UTF-8
3,059
2.859375
3
[ "MIT" ]
permissive
use clap::{App, Arg}; use std::{fs::File, io::prelude::*, path::Path}; use todo_finder_lib::{github, parser::IssueMap}; #[tokio::main] async fn main() { let cwd = std::env::current_dir().expect("could not get current dir"); let cwd_str = cwd.to_str().expect("could not convert cwd path"); let app = App::ne...
true
f05ffddd3075b7f717e44b2d8fbe56f5e031ee87
Rust
hamadakafu/kyopro
/src/bin/joi2008hoc.rs
UTF-8
1,090
2.8125
3
[]
no_license
use std::cmp::{max, min}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; use whiteread::parse_line; fn main() { let (n, m): (usize, usize) = parse_line().unwrap(); let mut pp: Vec<usize> = vec![]; for _ in 0..n { pp.push(parse_line().unwrap()); } let mut two = vec![];...
true
33e8828cb93a7698e8917138440a7252df1aff59
Rust
statiolake/class_number
/src/main.rs
UTF-8
18,928
3.0625
3
[]
no_license
use clap::Clap; use itertools::Itertools; use num::integer::gcd; use std::collections::{HashMap, HashSet}; use std::fmt; use std::sync::atomic::{AtomicBool, Ordering}; static MAKE_REPORT: AtomicBool = AtomicBool::new(false); macro_rules! write_report( ($($args:tt)*) => { if MAKE_REPORT.load(Ordering::SeqC...
true
86231ac5994071d82313fe62c982df67a822dc95
Rust
tyrchen/rust-training
/code/gp/src/lib.rs
UTF-8
1,507
3.890625
4
[]
no_license
use std::cmp::{Ord, Ordering}; pub trait LowBound<'a, T: Ord> { fn size(&self) -> usize; fn get(&self, pos: usize) -> &T; #[inline] fn partition(&self, start: usize, half: usize, value: &'a T) -> usize { let mid = start + half; match self.get(mid).cmp(value) { Ordering::Gre...
true
b29010fbae3e58e273d9c978284fdd039fd825b5
Rust
ten3roberts/vulkan-sandbox
/src/logger.rs
UTF-8
2,447
2.671875
3
[]
no_license
use log::*; use std::io; use std::io::Write; struct Logger; fn loglevel_ansi_color(level: Level) -> &'static str { match level { Level::Error => "\x1B[1;31m", Level::Warn => "\x1B[1;33m", Level::Info => "\x1B[1;34m", Level::Debug => "\x1B[1;35m", Level::Trace => "\x1B[1;36m...
true
21c8cdf5e627fe7210319bb8f4656f4775e5547d
Rust
tud-fop/rustomata
/search/src/search.rs
UTF-8
4,340
3.375
3
[ "BSD-3-Clause" ]
permissive
//! This module provides the `Search` type, an `Iterator` over nodes in a graph //! that is explored as an object of this type iterates. use crate::agenda::{binary_heap::weighted::BinaryHeap, weighted::Weighted, Agenda}; use std::collections::VecDeque; /// An `Iterator` exploring a graph with current frontier nodes i...
true
eb7f8e3043592bc0513a303c46eff80cbeb3d1a8
Rust
Arnavion/k8s-openapi
/src/v1_22/apiextensions_apiserver/pkg/apis/apiextensions/v1/custom_resource_definition_names.rs
UTF-8
15,302
2.640625
3
[ "Apache-2.0" ]
permissive
// Generated from definition io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionNames /// CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition #[derive(Clone, Debug, Default, PartialEq)] pub struct CustomResourceDefinitionNames { /// categories is a...
true
45e7f1e56a2c5484c984f2c9ebf94f36531e86e0
Rust
tylerhawkes/adventofcode2019
/src/bin/day05.rs
UTF-8
5,833
3.21875
3
[]
no_license
fn main() { //part 2 1377107 is too low let codes = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/inputs/day05.txt")).replace("\n", ""); let mut codes = codes .split(",") .filter_map(|s| { s.parse::<i32>() .map_err(|_| println!("Unable to parse {}", s)) .ok() }) .col...
true
fe0f50994296633c4b9b799699b93c3965a70995
Rust
EFanZh/LeetCode
/src/problem_0450_delete_node_in_a_bst/lift_right_min.rs
UTF-8
3,242
3.21875
3
[]
no_license
use crate::data_structures::TreeNode; pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::cell::RefCell; use std::cmp::Ordering; use std::rc::Rc; impl Solution { fn helper(root: &mut Option<Rc<RefCell<TreeNode>>>,...
true
3d3461249e7a407f7b8ebb4a46c0037f88399fc1
Rust
sfackler/rust-postgres-large-object
/src/lib.rs
UTF-8
13,245
2.9375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A crate providing access to the Postgres large object API. //! //! # Example //! //! ```rust,no_run //! extern crate postgres; //! extern crate postgres_large_object; //! //! use std::fs::File; //! use std::io; //! //! use postgres::{Connection, TlsMode}; //! use postgres_large_object::{LargeObjectExt, LargeObjectT...
true
1aae67212e304d7c6e42d752a08755063c7b2919
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc112/src/bin/d.rs
UTF-8
613
2.953125
3
[]
no_license
use proconio::input; fn divisors(n: usize) -> Vec<usize> { let mut d = vec![]; for i in 1.. { if i * i > n { break; } if n % i == 0 { d.push(i); if i != n / i { d.push(n / i); } } } d.sort(); d } fn mai...
true
db42a24539e31446994f6d6d7a19419ca0072f55
Rust
byronwasti/termsheets
/src/position.rs
UTF-8
929
3.546875
4
[]
no_license
use std::ops::{Add, Sub}; #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] pub struct CellPos { pub x: usize, pub y: usize, } impl CellPos { pub fn new(x: usize, y: usize) -> Self { Self { x, y } } pub fn offset(&self, other: &CellPos) -> (i32, i32) { let x = other.x as i32 - se...
true
eef4a59f8e3a8c34056f300ff114bfb2951e4702
Rust
cannontwo/factor_graph
/src/lib.rs
UTF-8
6,900
2.671875
3
[ "MIT" ]
permissive
#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces, unused_qualifications)] #![doc(html_root_url = "https://cannon10100.github.io/factor_graph/")] //! Crate allowing creation and manipulation of ...
true
dd9fc20d1f6a4572e4db233a15a64c18e76e2032
Rust
ashlink11/fibonacci_rust
/src/main.rs
UTF-8
850
3.921875
4
[]
no_license
/* Generate the nth Fibonacci number. Convert temperatures between Fahrenheit and Celsius. */ fn main() { println!("Hello, world!"); println!("Fib 1 is {}", fibonacci(1)); println!("Fib 2 is {}", fibonacci(2)); println!("Fib 3 is {}", fibonacci(3)); println!("Fib 4 is {}", fibonacci(4)); pri...
true
b42cf32b2dbf4ba2a142a9034723031bb5dabcae
Rust
josecm/exercism-rust
/minesweeper/src/lib.rs
UTF-8
1,140
2.65625
3
[]
no_license
pub fn annotate(minefield: &[&str]) -> Vec<String> { let mut ms: Vec<Vec<char>> = minefield.iter().map(|x| x.chars().collect()).collect(); let height = ms.len() as isize; let width = match height { 0 => 0, _ => ms[0].len(), } as isize; for (line, i) in ms.clone().iter().zip(0_isize....
true
619ac941aa768faf081689b10b1bdc62e77f1846
Rust
storyfeet/gravity
/src/play_edit/user.rs
UTF-8
4,946
2.71875
3
[]
no_license
use piston_window::{ButtonArgs,keyboard::Key,Button,Button::*,ButtonState}; use std::ops::{Sub,SubAssign}; use crate::ecs::{GenItem}; use crate::error::GravError; use crate::scene::SceneAction; use super::state::{State,Tile,GravCp,PlayMode,MoveAction}; use super::grid::{EdgeGrid}; use super::rects::{Position,UP,DOWN,...
true
dbcfed69765c1b5264cab1636b3c3b1cf066e728
Rust
599C-20wi/client
/src/admin.rs
UTF-8
1,821
3.046875
3
[]
no_license
use std::io::{BufRead, BufReader}; use std::net::{Shutdown, TcpListener, TcpStream}; use std::thread; const ADMIN_PORT: u16 = 3001; pub static mut DISTR_WEIGHTS: [u16; 2] = [50, 50]; pub fn start() { let listener = TcpListener::bind(format!("0.0.0.0:{}", ADMIN_PORT)).unwrap(); for stream in listener.incoming(...
true
9fc2b4ea4e577bdb699e3cf861544819e1574bc7
Rust
edwarburg/nocap
/src/typecheck/assignable.rs
UTF-8
7,245
2.90625
3
[]
no_license
use crate::ty::*; use bumpalo::core_alloc::fmt; use bumpalo::core_alloc::fmt::{Display, Formatter}; pub(crate) trait CheckAssignable where Self: Display, { // TODO some type context parameter probably needs to be threaded through here fn assignable(from: &Self, to: &Self) -> AssignabilityJudgment; fn ...
true
fbfe97894044bff7feba56a25df8a333b7f75281
Rust
roelanto/AdventOfCode
/2020/day02/src/main.rs
UTF-8
4,016
3.015625
3
[]
no_license
use aoc_lib; use regex::Regex; use std::io::{self, BufRead}; fn read_and_parse(st: &str) -> Vec<String> { let split = st.split(" ").collect::<Vec<&str>>(); let splitst = split.iter().map(|x| String::from(*x)).collect(); return splitst; } fn create_regexp(minmax: &str, _character: &str) -> String { let...
true
249c98adfe797c2acf590f5265cc9c31757e5015
Rust
Spanfile/Routing-Platform
/crates/rp_shell/src/shell/completions.rs
UTF-8
624
3
3
[]
no_license
use rp_log::*; #[derive(Debug)] pub struct Completions { commands: Vec<&'static str>, } impl Completions { pub fn new(commands: Vec<&'static str>) -> Self { debug!("Completions: commands: {:?}", commands); Completions { commands } } pub fn get(&self, input: String) -> anyhow::Result<V...
true
ee46ff40442eaf52b249d628a9d0bce5e5e34d6a
Rust
ducklin5/godot-rust-cli
/tests/command-new.rs
UTF-8
5,919
2.859375
3
[ "MIT" ]
permissive
use assert_cmd::prelude::*; use serde_json::{json, Value}; use std::error::Error; use std::fs::read_to_string; use std::path::Path; use std::process::Command; mod test_utilities; use test_utilities::{cleanup_test_files, init_test, Gdnlib}; /// Creates a library and checks that all of the files in the library exist /...
true
da13e984870357aaad9afe6939cc94a8d293fc16
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_509/src/solution6.rs
UTF-8
627
3.453125
3
[ "MIT" ]
permissive
// 时间复杂度 O(n) 的递归 impl Solution { pub fn fib(n: i32) -> i32 { Solution::fib_inner(n, 0, 0, 1) } fn fib_inner(n: i32, i: i32, f1: i32, f2: i32) -> i32 { if i == n { return f1; } Solution::fib_inner(n, i + 1, f2, f1 + f2) } } pub struct Solution; #[cfg(test)] mod tests { use super::*; ...
true
8c98d8172a143aeb10b406dc55ff0f018600048a
Rust
jasonblog/note
/Rust/code/learn_rust/learn_err1/src/main.rs
UTF-8
825
3.34375
3
[]
no_license
//1、rust语言将错误分为两个类别:可恢复错误和不可恢复错误 //(1)可恢复错误通常代表向用户报告错误和重试操作是合理的情况,例如未找到文件。rust中使用Result<T,E>来实现。 //(2)不可恢复错误是bug的同义词,如尝试访问超过数组结尾的位置。rust中通过panic!来实现。 //2、panic! //3、使用BACKTRACE=1 //4、Result<T, E> //enum Result<T, E> { // Ok(T), // Err(E), //} //5、简写 use std::fs::File; fn main() { //let f = File::open("hello.t...
true
4ed731c00d208aad1b30eeeb5e02a89e1b64c220
Rust
djcal460/Rust-Dynamic-Programming-Hotel-Problem
/src/main.rs
UTF-8
1,442
3.375
3
[]
no_license
fn main() { let hotels: [i32;7] = [0,50,75,200,399,600,2000]; println!("Your array of hotels by distance: {:?}",hotels); let vec = opt_travel(&hotels); println!("The optimal sequence of hotels with minimum penalty is: {:?}",vec); } pub fn opt_travel(hotels: &[i32]) -> Vec<i32> { let mut opt...
true
b800997495f4dfdc5aa4f86a089a907f1e51d001
Rust
jeschkies/influxdb_iox
/object_store/src/path.rs
UTF-8
12,232
3.234375
3
[ "Apache-2.0", "MIT" ]
permissive
//! This module contains code for abstracting object locations that work //! across different backing implementations and platforms. use itertools::Itertools; use percent_encoding::{percent_decode_str, percent_encode, AsciiSet, CONTROLS}; use std::path::PathBuf; /// Universal interface for handling paths and location...
true
9a46d2b0c07394139807208f5ae9f81b26643fcc
Rust
cldershem/azul
/src/lib.rs
UTF-8
8,774
2.859375
3
[ "MIT" ]
permissive
//! Azul is a free, functional, IMGUI-oriented GUI framework for rapid prototyping //! of desktop applications written in Rust, supported by the Mozilla WebRender rendering //! engine, using a CSS / DOM model for layout and styling. //! //! ## Concepts //! //! Azul is largely based on the IMGUI principle, in that you r...
true
eecfa620fd6df24a88d99d2049ff3ef012c6d7c0
Rust
sayamapp/my_n2t_kani
/08/vm_translator/src/parser.rs
UTF-8
3,827
3.484375
3
[]
no_license
use std::fs::File; use std::io::Read; #[derive(Debug)] pub struct Parser { name: String, lines: Vec<String>, idx: usize, } impl Parser { pub fn new(path: &str, name: &str) -> Self { let file_name = format!("{}{}", path, name); let mut file = File::open(file_name).expect("File not found!...
true
23aa8938d91f810cd4dc56938699e4b38dd527bf
Rust
jhagans3/creative-projects-for-rust-programmers
/storing-and-retrieving-data/src/bin/toml_static.rs
UTF-8
1,689
3.296875
3
[]
no_license
// Serialization is the process of converting data structures of // the program into a string (or a stream) // Deserialization is the reverse process it is the process of // converting a string (or a stream) into some data structures of the program. // To read a TOML file, we need to use deserialization. // we don't ne...
true
c61e0d926fc8eaf2019da3d539e913665d4d2b40
Rust
jonfk/utility-belt
/rust/cmd-queue/src/task.rs
UTF-8
2,212
2.859375
3
[ "MIT" ]
permissive
use std::{ ops::Add, process::Command, sync::Arc, time::{Duration, SystemTime}, }; use crate::{error::CmdqError, queue::InMemoryQueue, QueueState, TaskRunResult}; const MAX_RETRIES: usize = 20; const MAX_DELAY_SECONDS: u64 = 600; const DELAY_SECONDS: u64 = 2; pub struct TaskService { queue: Arc<I...
true
83b1646b81b0e5acaa0be9967fff37986737d171
Rust
slpdex/cashcontracts-rs
/src/address.rs
UTF-8
6,441
2.71875
3
[]
no_license
use crate::hash::hash160; const CHARSET: &[u8] = b"qpzry9x8gf2tvdw0s3jn54khce6mua7l"; const DEFAULT_PREFIX: &str = "bitcoincash"; #[derive(Clone, Debug)] pub enum AddressError { InvalidChecksum, InvalidBase32Letter(usize, u8), InvalidAddressType(u8), } #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] p...
true
a0a8a3c1897938c8a3c299dec4da4e2724da7031
Rust
killercup/wundergraph
/wundergraph_derive/src/meta.rs
UTF-8
6,311
2.75
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use proc_macro2::Span; use syn; use syn::spanned::Spanned; use syn::fold::Fold; use utils::*; use diagnostic_shim::*; pub struct MetaItem { meta: syn::Meta, } impl MetaItem { pub fn all_with_name(attrs: &[syn::Attribute], name: &str) -> Vec<Self> { attrs .iter() .filter_map(|a...
true
7357cec867599123502cf69ef60aa178322b1a87
Rust
kjn-void/advent-of-code-2019
/src/day3/mod.rs
UTF-8
3,492
3.4375
3
[ "MIT" ]
permissive
use regex::Regex; use std::collections::HashMap; use super::Solution; use super::vec2d::*; struct Movement { dir: Dir, distance: Distance, } fn dir_parse(repr: &str) -> Dir { match repr { "U" => Dir::Up, "D" => Dir::Down, "R" => Dir::Right, "L" => Dir::Left, _ => pa...
true
8b4643953dab11143743f085c8619f26fa5a29ca
Rust
Arnavion/k8s-openapi
/src/v1_22/api/core/v1/service_port.rs
UTF-8
15,463
2.875
3
[ "Apache-2.0" ]
permissive
// Generated from definition io.k8s.api.core.v1.ServicePort /// ServicePort contains information on service's port. #[derive(Clone, Debug, Default, PartialEq)] pub struct ServicePort { /// The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved fo...
true
7c290de852e732ba9354b5f4d19d5e6b2200f1e2
Rust
wlp2s0/rust-todo
/src/main.rs
UTF-8
1,410
2.84375
3
[ "Apache-2.0" ]
permissive
use actix_web::{get, post, App, HttpResponse, HttpServer, Responder}; mod models; mod settings; use crate::{models::Note, settings::APP_SETTINGS}; #[get("/")] async fn hello() -> impl Responder { HttpResponse::Ok().json(Note { title: "Lorem Ipsum".to_string(), description: "Contrary to popular be...
true
015f0eec485d52a9a92eea6375ebd4b42566fccd
Rust
roynalnaruto/core
/crates/sol-types/src/util.rs
UTF-8
3,024
3.125
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2015-2020 Parity Technologies // Copyright 2023-2023 Alloy Contributors // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be c...
true
76be69523234e71b597d6e6e378db2ebed9bcec5
Rust
simongalasso/cg_mars_lander_ga
/src/display/display.rs
UTF-8
3,805
2.5625
3
[]
no_license
extern crate glutin_window; extern crate graphics; extern crate opengl_graphics; extern crate piston; use piston::window::WindowSettings; use piston::input::*; use glutin_window::GlutinWindow; use opengl_graphics::{GlGraphics, OpenGL}; use crate::display::display::graphics::Transformed; use crate::game::game::*; use ...
true
1807d5f6f5be17420351315847c1a49be122e148
Rust
spadix0/AoC2020
/24/hextile/src/main.rs
UTF-8
3,138
3.15625
3
[]
no_license
use std::io; use fxhash::{ FxHashMap as HashMap, FxHashSet as HashSet, }; type Coord = u64; // 2x bit packed components const B: Coord = 32; // bits / component -1 for separation const M: Coord = (1 << B-1) - 1; // component mask const MASK: Coord = M | M<<B; // Coord 2-tuple mask const DIRS: &[Coord] = ...
true
db7990cea9c6a12ee73482d45c9be0389c8aed9b
Rust
astral-sh/ruff
/crates/ruff/src/rules/flake8_slots/rules/helpers.rs
UTF-8
907
2.671875
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
use ruff_python_ast::{self as ast, Expr, Stmt}; /// Return `true` if the given body contains a `__slots__` assignment. pub(super) fn has_slots(body: &[Stmt]) -> bool { for stmt in body { match stmt { Stmt::Assign(ast::StmtAssign { targets, .. }) => { for target in targets { ...
true
687a5b684631d1f81a04d9da6dac93d23d876ffb
Rust
dsifford/CSC_6500
/homework/homework_06/simulated-annealing/src/main.rs
UTF-8
779
3.453125
3
[]
no_license
extern crate rand; use rand::distributions::{Distribution, Uniform}; use rand::prelude::ThreadRng; use rand::thread_rng; fn main() { let result = minimize(); println!("Optimum value of x = {}", result) } fn minimize() -> i32 { let mut rng = thread_rng(); let mut result: i32 = random_num(&mut rng); ...
true
a9f4bd98c30db71fa9ef9f87074501a3ad0e86d8
Rust
blhough/tictac
/src/game/ult.rs
UTF-8
4,658
2.859375
3
[]
no_license
use crate::game::entry::*; use crate::game::*; use crate::game::entry::Entry::*; use crate::game::board::TicTac; use rand::Rng; use std::collections::HashSet; use rand::seq::SliceRandom; #[derive(Debug, Clone)] pub struct Ult { pub brds: Vec<TicTac>, wins: Vec<Option<Entry>>, last_move: Option<Move>, open: [HashS...
true
0b5439e682415ea49e8962efb81a36f30193ef98
Rust
heyrutvik/pikelet
/crates/pikelet-concrete/tests/check.rs
UTF-8
6,907
2.546875
3
[ "Apache-2.0" ]
permissive
use codespan::CodeMap; use pikelet_concrete::desugar::{Desugar, DesugarEnv}; use pikelet_concrete::elaborate::{self, Context, TypeError}; mod support; #[test] fn record_intro() { let mut codemap = CodeMap::new(); let context = Context::default(); let expected_ty = r"Record { t : Type; x : String }"; ...
true
19a741e3f85243301d01ec96c390505b28a49281
Rust
coeuvre/flappy-bird-rs
/src/gfx/image/mod.rs
UTF-8
5,762
2.84375
3
[]
no_license
use std; use std::path::Path; use std::fs::File; use std::io::prelude::*; use std::io; use std::ffi::CStr; mod stb_image; use self::stb_image::*; pub enum SupportedImageStorage { Rgba8(ImageStorage<Rgba8>), A8(ImageStorage<A8>), } pub struct GeneralImage { w: u32, h: u32, storage: SupportedImage...
true
c8ed346c5feb5e6952ae9f54228ffd65ce5f9449
Rust
kjn-void/advent-of-code-2019
/src/day23/mod.rs
UTF-8
2,879
2.859375
3
[ "MIT" ]
permissive
use super::intcode::*; use super::Solution; use std::env; use std::sync::mpsc::channel; impl Solution for Day23 { fn part1(&self) -> String { let mut nics = Vec::new(); for addr in 0..50 { let (input, sink) = channel(); let output = exec(&self.program, sink, None); ...
true
78eb75f26347878b7c552868f228a52562e76972
Rust
rnestler/relative-linked-list-rs
/src/lib.rs
UTF-8
3,323
3.96875
4
[]
no_license
#[derive(Debug, PartialEq, Eq)] pub struct Node { data: i32, next: Option<usize>, } #[derive(Debug)] pub struct LinkedList { data: Vec<Node>, head: Option<usize>, empty_head: Option<usize>, } pub struct Iter<'a> { data: &'a Vec<Node>, current_index: Option<usize>, } impl<'a> Iterator for ...
true
99bc001623f3445766926b63004da1976ebfb62e
Rust
cjburkey01/cjemu
/cjemu-runtime/src/alu.rs
UTF-8
2,085
2.828125
3
[ "MIT" ]
permissive
use cjemu_api::{Alu, AluOutputs}; pub struct CJEmuAlu {} #[allow(unused_variables)] impl Alu for CJEmuAlu { fn add16(&mut self, a: u16, b: u16) -> AluOutputs { let (value, overflow) = match a.checked_add(b) { Some(val) => (val, false), // Wrap back around in the event of an overflo...
true
26708a088fe5b753b1268309cbd34307c64f2dc7
Rust
RaymondK99/advent_of_code_2019
/src/util/day_06.rs
UTF-8
3,276
3.359375
3
[]
no_license
use crate::util::Part; use std::collections::HashMap; pub fn solve(input:String, part:Part) -> String { let mut planets:HashMap<String, Vec<String> > = HashMap::new(); // Build up system for pair in input.lines().map(|l| l.trim().to_string()) { let pars:Vec<String> = pair.split(')').map(|p| p.to_...
true
4612bc29805f25845434615ea9eb83a00e956fa6
Rust
mbillingr/raytracing
/rust/src/shapes/csg.rs
UTF-8
9,940
3.109375
3
[]
no_license
use crate::aabb::Aabb; use crate::matrix::Matrix; use crate::ray::{sort_intersections, Intersection, Ray}; use crate::shapes::{SceneItem, Shape}; pub fn csg_union(s1: impl Into<SceneItem>, s2: impl Into<SceneItem>) -> CsgPair { CsgPair::new(CsgOp::Union, s1, s2) } pub fn csg_difference(s1: impl Into<SceneItem>, s...
true
5a747eda5dd9f736c43da804a8aacf8f0290fb42
Rust
bklooste/simag
/src/bin/repl.rs
UTF-8
11,458
2.8125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A REPL (Read-Eval-Print-Loop) terminal interface for the language extern crate termion; extern crate simag_core; use std::io::{Read, Write, Bytes, stdout}; use std::time; use simag_core::utils::{Interpreter, SimagInterpreter, Action}; use termion::event::{Event, Key, parse_event}; use termion::raw::IntoRawMode; ...
true
d00bf5ee050a799042f674e8f6d3b6bb0916d1e5
Rust
deep-rust/deep
/deep/src/lib.rs
UTF-8
3,518
2.859375
3
[ "MIT" ]
permissive
#[macro_use] extern crate strum_macros; mod tensor; pub use tensor::Tensor; use rand_core::RngCore; #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Internal { /// The node to pull the input tensor from. pub node: usize, /// The specific output to pull from. pub output:...
true
18939b57c34200bd56704f70998400c12955fae6
Rust
magiclen/bulls-and-cows
/src/play/players/player.rs
UTF-8
758
3.40625
3
[ "MIT" ]
permissive
use std::hash::Hash; /// A player who asks questions in the game. pub trait Questioner<T: Eq + Hash + Clone> { type Error; /// Make a new question. fn make_new_question(&mut self); /// Answer for the question. fn answer(&self, answer: &[T]) -> Result<(usize, usize), Self::Error>; } /// A player ...
true
327f7adc4a581e814ffccd7f150413b2ddea1d4e
Rust
pandaa880/codeforces_practice_rust
/Round_722_Rated_Div2/problem_a/src/main.rs
UTF-8
2,450
3.5
4
[]
no_license
/* Eshag loves Big Arrays */ use std::io; use std::process; fn main() { let mut t = read_number(); let mut results = Vec::new(); while t != 0 { let n = read_number(); let nums = read_numbers(n); let mut sorted_numbers = sort_numbers(nums); let r = max_delete(&mut sorted_nu...
true
f17d4094ec0a26b6ef2d6a5c5e0547744be1a3f0
Rust
Pecco-314/pdg
/src/random.rs
UTF-8
4,424
3.203125
3
[ "Apache-2.0" ]
permissive
use crate::{ resolve, token::{RandomString, RandomString::*, *}, }; use num::cast::ToPrimitive; use rand::{seq::SliceRandom, thread_rng}; macro_rules! distribute { ($output:ty; $($freq:expr, $func:expr);+) => {{ let mut v: Vec<(usize, fn() -> Option<$output>)> = Vec::new(); $(v.push(($freq, ...
true
63c8deefa0e3e78842cc1ea8f7efa13e2e597c99
Rust
mbillingr/AOC19
/day18/src/main.rs
UTF-8
11,277
2.875
3
[]
no_license
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque}; use std::fs::File; use std::io::Read; fn main() { let mut input = String::new(); File::open("data/day18-input.txt") .unwrap() .read_to_string(&mut input) .unwrap(); let (map, start_pos) = parse_map(&input); let edg...
true
803ec16c0e12b699d4be795b77e11792913c3710
Rust
fractal-86/taocp
/mix/src/computer.rs
UTF-8
95,504
3
3
[]
no_license
use crate::arch; use crate::instructions; use crate::io; use crate::timing; use std::cmp; use instructions::Instruction; struct Registers { a: arch::Word, x: arch::Word, i1: arch::HalfWord, i2: arch::HalfWord, i3: arch::HalfWord, i4: arch::HalfWord, i5: arch::HalfWord, i6: arch::HalfWor...
true
558ac6c9d1de980377a03e1e3c40a3459a5994c0
Rust
erikjohnston/casniam
/src/protocol/events/mod.rs
UTF-8
4,570
2.765625
3
[]
no_license
pub mod v2; pub mod v3; use failure::Error; use serde_json::Value; use crate::protocol::{Event, RoomState, RoomVersion}; use crate::stores::{EventStore, StateStore}; #[derive(Clone, Debug)] pub struct EventBuilder { event_type: String, state_key: Option<String>, sender: String, content: serde_json::M...
true
bbc56c74284a96f92656eddb3e7c096caebb9152
Rust
joshuarli/fd
/src/app.rs
UTF-8
33,992
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
use clap::{crate_version, AppSettings, Arg, ColorChoice, Command}; pub fn build_app() -> Command<'static> { let clap_color_choice = if std::env::var_os("NO_COLOR").is_none() { ColorChoice::Auto } else { ColorChoice::Never }; let mut app = Command::new("fd") .version(crate_versi...
true
1c9e62735b3c4aacb8b07e270fef3a5906da55bc
Rust
povilasb/rust-playground
/binary-heap/src/main.rs
UTF-8
4,372
3.25
3
[]
no_license
#[cfg(test)] #[macro_use] extern crate hamcrest; use std::io; use std::str::FromStr; use std::fmt::Debug; struct MinHeap { items: Vec<i64>, } impl MinHeap { fn new() -> MinHeap { MinHeap { items: Vec::new(), } } fn push(&mut self, item: i64) { self.items.push(item...
true
2b628b3ed44a949d15c36b784f486dc1f794d7ac
Rust
iamfauz/cpen442-miner
/src/util.rs
UTF-8
1,930
3.171875
3
[]
no_license
use crate::cpen442coin; use std::time::{Duration, Instant}; pub struct Timer { start : Instant, period : Duration } impl Timer { pub fn new(period : Duration) -> Self { Timer { start : Instant::now(), period } } pub fn check_and_reset(&mut self) -> bool { ...
true
abca74738e679f85bd905f2291f1b9f2744fa95e
Rust
HerringtonDarkholme/leetcode
/src/152_maximum_product.rs
UTF-8
642
3.25
3
[]
no_license
struct Solution; impl Solution { pub fn max_product(nums: Vec<i32>) -> i32 { max_product(nums) } } fn max_product(nums: Vec<i32>) -> i32 { if nums.len() == 1 { return nums[0] } let mut pos = 0; let mut neg = 0; let mut max = nums[0]; for n in nums { if n == 0 { ...
true
dfe7e324b34edbcfe4df22eda8117e16a9720f08
Rust
fabianbadoi/rusty-pine
/libs/src/query/structure.rs
UTF-8
2,367
2.765625
3
[]
no_license
use crate::common::{BinaryFilterType, UnaryFilterType}; #[derive(Debug, Eq, PartialEq)] pub enum Renderable { Query(Query), Meta(RenderableMetaOperation), } #[derive(Debug, Eq, PartialEq)] pub enum RenderableMetaOperation { ShowNeighbours(TableName), ShowColumns(TableName), } #[cfg(test)] impl Render...
true
452cf76f0f7a25ea6e6d88a19f89fd5dca2b8dc8
Rust
aertoria/exonum
/testkit/tests/inflating_currency/main.rs
UTF-8
7,113
2.578125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2018 The Exonum Team // // 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 i...
true
e67b998418d3b19132bb43a0d74fcff5eb38486a
Rust
emmanueltouzery/zbus
/zbus/src/handshake.rs
UTF-8
23,283
2.75
3
[ "MIT" ]
permissive
use std::convert::TryInto; use std::env; use std::io::BufRead; use std::os::unix::io::AsRawFd; use std::os::unix::net::UnixStream; use std::str::FromStr; use nix::poll::PollFlags; use nix::unistd::Uid; use crate::address::Address; use crate::guid::Guid; use crate::raw::{Connection, Socket}; use crate::utils::wait_on;...
true
b128c72cf2a2b56a7fc965748641e84a1314fb35
Rust
happydpc/system-viewer
/src/managers/scene/component_storage/hash_storage.rs
UTF-8
2,909
3.15625
3
[ "MIT", "CC-BY-4.0" ]
permissive
use crate::components::Component; use crate::managers::scene::component_storage::ComponentStorage; use crate::managers::scene::Entity; use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HashStorage<T: Component> { storage: HashMap...
true
9caf6bfb1a51827370d2dffc091f2fb928cf0d65
Rust
AldaronLau/crossterm-pasts
/src/main.rs
UTF-8
1,840
2.953125
3
[ "Apache-2.0" ]
permissive
use std::{ io::{stdout, Write}, task::{Context, Poll}, pin::Pin, future::Future, }; use pasts::prelude::*; use futures_core::stream::Stream; use crossterm::{ cursor::position, event::{DisableMouseCapture, EnableMouseCapture, Event, EventStream, KeyCode}, execute, terminal::{disable_ra...
true
4f894b450a4ec2162ae3a4b31ddf0637635ffcb3
Rust
TurtlePU/elliptic
/src/algebra/zp.rs
UTF-8
3,458
2.828125
3
[]
no_license
use std::{ convert::TryInto, iter::Sum, ops::{Add, Mul, Neg, Sub}, }; use num_bigint::{BigInt, BigUint}; use num_traits::{Inv, One, Pow, Zero}; use rand::{distributions::Standard, prelude::Distribution}; use thiserror::Error; use crate::bytes::{Decoding, Deserialize, Encoding, Serialize}; use super::{ ...
true
9c0178203039d70a701b6f4f9d5e8b7afb6d647a
Rust
agerasev/ringbuf
/blocking/src/rb.rs
UTF-8
2,928
2.546875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[cfg(feature = "std")] use crate::sync::StdSemaphore; use crate::{ halves::{BlockingCons, BlockingProd}, sync::Semaphore, traits::{BlockingConsumer, BlockingProducer}, }; #[cfg(feature = "alloc")] use alloc::sync::Arc; use core::time::Duration; #[cfg(feature = "alloc")] use ringbuf::traits::Split; use ring...
true
5b77e91b5470ccc828d57b4b4d132fc911310578
Rust
cstorey/rustbucks
/infra/src/untyped_ids.rs
UTF-8
7,881
2.8125
3
[ "Apache-2.0" ]
permissive
use std::convert::TryInto; use std::fmt; use std::hash::{Hash, Hasher}; use std::time::{Duration, SystemTime}; use anyhow::Error; use data_encoding::BASE32_DNSSEC; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use crate::ids::{Id, IdGen, IdParseError, ENCODED_BARE_ID_LEN}; #[derive(Debug, Partia...
true
3fdbc6d963673489554ebc2af991b312ebe2260d
Rust
SamuelLorrain/habit_tracker
/src/cli/mod.rs
UTF-8
9,449
3.078125
3
[]
no_license
pub mod database_handling; use regex::Regex; use std::collections::HashMap; use std::env; use database_handling::*; pub enum ArgumentTypes<A,B,C> { TypeA(A), TypeB(B), TypeC(C), } pub fn print_help() { print!( "habit_tracker\n\ A simple habit tracker with stats\n\n\ USAGE:\n\ ...
true
335098344f64beadcc6d9a636bcd0f4327ba0f1b
Rust
foxfriends/syncat
/syncat-stylesheet/src/ast/declaration.rs
UTF-8
1,022
2.9375
3
[]
no_license
use std::collections::BTreeMap; use std::iter::FromIterator; use tree_sitter::TreeCursor; use super::{helper::*, Value, Variable}; #[derive(Clone, Debug)] pub(crate) struct Declaration { pub(crate) variable: Variable, pub(crate) value: Value, } impl FromSource for Declaration { fn from_source(tree: &mut T...
true
b2f6c9e16166f32d721cd48393c0a7e2198b311d
Rust
kevinbader/pwmd
/src/pwm.rs
UTF-8
11,312
3.359375
3
[ "MIT" ]
permissive
use std::{ fmt::Display, fs, path::{Path, PathBuf}, str::FromStr, time::Duration, }; use thiserror::Error; use tracing::{debug, instrument}; /// Everything that can go wrong. #[derive(Error, Debug)] pub enum PwmError { #[error("{0:?} not found")] ControllerNotFound(Controller), #[error...
true
a118881038357ad5c0c5a11c6553c10b027f6f1c
Rust
sile/httpcodec
/src/options.rs
UTF-8
775
2.90625
3
[ "MIT" ]
permissive
/// Options for request/response decoders. #[derive(Debug, Clone)] pub struct DecodeOptions { /// The maximum number of bytes allowed for a start-line part. pub max_start_line_size: usize, /// The maximum number of bytes allowed for a header part. pub max_header_size: usize, } impl DecodeOptions { ...
true
687a560d5837965f7425aef96fddd60ef0594dc9
Rust
eliasyaoyc/k8s-openapi
/k8s-openapi-codegen-common/templates/watch_event_bookmark_object.rs
UTF-8
6,229
2.703125
3
[ "Apache-2.0" ]
permissive
#[derive(Debug, PartialEq)] struct BookmarkObject<'a> {{ metadata: BookmarkObjectMeta<'a>, }} #[derive(Debug, PartialEq)] struct BookmarkObjectMeta<'a> {{ resource_version: std::borrow::Cow<'a, str>, }} impl<'de> {local}serde::Deserialize<'de> for BookmarkObject<'static> {{ fn deserialize<D>(deserializer...
true
63acbeccc3a0a4194ab4502bcb21ecac3b5ceb41
Rust
gabdube/native-windows-gui
/native-windows-gui/src/controls/progress_bar.rs
UTF-8
13,222
2.9375
3
[ "MIT" ]
permissive
/*! A push button is a rectangle containing an application-defined text label, an icon, or a bitmap that indicates what the button does when the user selects it. */ use winapi::um::winuser::{WS_VISIBLE, WS_DISABLED}; use winapi::um::commctrl::{PBS_MARQUEE, PBS_VERTICAL}; use crate::win32::window_helper as wh; use crat...
true
6532b1c251437d35266acf5481b7e6b149de5b44
Rust
gregokent/tms570
/src/dcan4/intpnd56/mod.rs
UTF-8
25,537
2.5625
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u32, } impl super::INTPND56 { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: self.register.get() } } } #[doc = r" Value of the field"] pub struct INTPND96R { bits: bool, } impl I...
true
8d947b6f57f7ba1f76d425a5d889faad151fb2f4
Rust
BraydenNeale/rust_exercism
/hamming/src/lib.rs
UTF-8
702
3.640625
4
[]
no_license
pub fn hamming_distance(dna1: &str, dna2: &str) -> std::result::Result<u32, &'static str> { if dna1.chars().count() != dna2.chars().count() { return Err("Can't compare unequal strand lengths"); } Ok(dna1.chars() .enumerate() .fold(0,|sum, (i, ch)| { sum + (dna2.chars().nth(i).unwrap() != ch) as u32 }) )...
true
39b8fe01a8435e9248dd8bba1b89e7b2b1730652
Rust
toasterrepairman/FLTK-RS-Examples
/fuzzy_search/src/main.rs
UTF-8
5,168
2.75
3
[]
no_license
use fltk::{prelude::*, *, image::*}; // const IMG: &str = include_str!("./search-24px.svg"); fn main() { let app = app::App::default().with_scheme(app::Scheme::Gtk); let mut wind = window::Window::default().with_size(402, 275); let mut table = table::Table::default().size_of(&wind); table.set_rows(8)...
true
f5428c65c9e219ef9328907c4ba32d1ed68797aa
Rust
burrbull/libm
/src/math/musl/ilogb.rs
UTF-8
857
2.953125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::f64; #[allow(clippy::eq_op)] const FP_ILOGBNAN: isize = -1 - ((!0) >> 1); const FP_ILOGB0: isize = FP_ILOGBNAN; /// Get exponent (f64) /// /// All nonzero, normal numbers can be described as `m*2^p`. /// Examines the argument `x`, and returns *p*. pub fn ilogb(x: f64) -> isize { let mut i: u64 = x.to_bi...
true
b2c8547ed3cd8eb4e955b40591cb96bcf0b44993
Rust
CCS-1L-F19/dbgm
/src/gui/resources.rs
UTF-8
1,237
2.546875
3
[ "MIT" ]
permissive
use crate::renderer::{Textures, Texture}; macro_rules! load_internal_texture { {$textures:ident, $path:tt} => { { let image = image::load_from_memory(include_bytes!($path)).expect("Failed to load internal texture!"); $textures.create_texture(&image).expect("Failed to create internal texture!") ...
true
4a44aca3fc55e761c2650adf9109ab8489e6b962
Rust
ROki1988/ot-rs
/src/api/trace/scope.rs
UTF-8
1,591
2.75
3
[ "MIT" ]
permissive
use crate::api::trace::Span; struct Scope<F, S> { f: F, span: S, } impl<'a, F, U, S> Scope<F, S> where F: Fn() -> U, S: Span<'a>, { fn new(span: S, f: F) -> Self { Self { f, span } } fn run(&mut self) -> U { let f = &self.f; let rt = f(); self.span.end(); ...
true