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
fe68962e086e46b792311a5e4fd404240eb7ff5f
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/signal-hook-0.1.17/src/cleanup.rs
UTF-8
8,266
3.1875
3
[ "BSD-2-Clause", "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Cleaning up signals. //! //! The routines in this module allow resetting the signals of an application back to defaults. //! This is intended for the following situation: //! //! * A terminal signal (eg. a `SIGTERM`, `SIGINT` or something similar) is received. //! * The application resets the signal handlers to def...
true
1ce97dca1d5dc615e724f470a75ea6cfad427ab1
Rust
eyeplum/rust-unic
/gen/src/source/emoji/emoji_data.rs
UTF-8
2,826
2.796875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2017 The UNIC Project Developers. // // See the COPYRIGHT file at the top-level directory of this distribution. // // 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>, a...
true
0a6aeb094be12fbcda3338eb17ed07bd807c8e8d
Rust
evanjs/lorri
/src/watch.rs
UTF-8
17,249
3.125
3
[ "Apache-2.0" ]
permissive
//! Recursively watch paths for changes, in an extensible and //! cross-platform way. use crate::NixFile; use crossbeam_channel as chan; use notify::event::ModifyKind; use notify::{EventKind, RecommendedWatcher, RecursiveMode, Watcher}; use slog_scope::{debug, info}; use std::collections::HashSet; use std::path::{Path...
true
a64ec5270856319670f9b719d8dbd6116ce3dbe9
Rust
nipzu/mandelbrot-drawer
/src/webgl.rs
UTF-8
7,830
2.5625
3
[ "MIT" ]
permissive
use js_sys::{WebAssembly, Uint32Array}; use wasm_bindgen::JsCast; use web_sys::{OffscreenCanvas, WebGl2RenderingContext, WebGlProgram, WebGlShader}; use crate::{CalculateEscapeTimes, RenderingState}; pub struct WebGLRenderer { canvas: OffscreenCanvas, context: WebGl2RenderingContext, program: WebGlProgram,...
true
14a0cb4201a27f269c34e39df943f6781b566586
Rust
drahnr/yubihsm-rs
/src/credentials.rs
UTF-8
1,181
3.15625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use auth_key::AuthKey; use object::ObjectId; /// Default auth key ID slot pub const DEFAULT_AUTH_KEY_ID: ObjectId = 1; /// Credentials used to establish a session with the HSM pub struct Credentials { /// Key ID to authenticate with pub auth_key_id: ObjectId, /// Auth key to authenticate with pub aut...
true
1b09a2055224ab285e14d91e40c1c171e3ac1b85
Rust
szhongren/rust_learn
/13_scoping_rules/1_raii.rs
UTF-8
619
3.40625
3
[]
no_license
// rust variables hold values and also own resources // raii stands for resource acquisition is initialization // when an object goes out of scope its destructor is called and owned resources are freed fn create_box() { // allocate an int on the heap let _box1 = Box::new(3i32); // _box1 destroyed here...
true
6cef1485abbf84f5d83549ce30e5ba50d87c2906
Rust
walteralleyz/sys_academia_rust
/src/repository.rs
UTF-8
2,398
3.359375
3
[]
no_license
use std::io::stdin; use crate::model::User; use crate::utils::{input_string, input_u8, input_f32}; pub struct Repository { pub database: Vec<User> } impl Repository { pub const fn new() -> Self { Repository { database: Vec::new() } } pub fn validate_index(&self) -> usize { let mut id ...
true
28804e37374cebf79f5fc5dc9795ccdf22771163
Rust
KappaShilaff/try_api
/src/main.rs
UTF-8
6,314
2.5625
3
[]
no_license
use warp::{http, Filter}; use crate::models::{AccountId}; use crate::account::AccountRepo; use crate::dto::{CreateAccountDto, SignAndGetDto, UpdateAccountDto, GetApiKeyDto}; use crate::db::{db_connect}; use std::sync::Arc; mod account; mod models; mod dto; mod db; mod docs; fn json_body<T>() -> impl Filter<Extract=(T...
true
8821a87b7d226ab5cb1fd24bfdcc870a5ec5a42c
Rust
seungha-kim/hcc
/src/main.rs
UTF-8
692
2.71875
3
[]
no_license
extern crate hcc; use std::error; use std::io; use hcc::basic::Interpreter; use std::io::Write; fn main() { loop { print!("calc> "); // https://github.com/rust-lang/rust/issues/23818 stdout_flush(); match interprete() { Ok(result) => println!("{}", result), ...
true
e24fe0edae3defe21a00c748fec0e4708f116470
Rust
konstin/demos
/oparl-cache-rs/src/main.rs
UTF-8
2,214
2.953125
3
[]
no_license
//! This file defines a CLI for the OParlCache crate //! Use `cargo run -- --help` to get information on the available options extern crate oparl_cache; #[macro_use] extern crate clap; extern crate reqwest; use std::error::Error; use std::path::Path; use reqwest::IntoUrl; use oparl_cache::{Cacher, FileStorage, Comm...
true
69c1dd10dca64c96c2556a7d6f61d6cc5f9f20db
Rust
caquillo07/learning-rust
/ch8_1_vectors/src/main.rs
UTF-8
1,061
3.78125
4
[]
no_license
fn main() { println!("Hello, world!"); let mut v = vec![1, 2, 3, 4, 5]; let third: &i32 = &v[2]; println!("the third element is {}", third); match v.get(2) { Some(third) => println!("the third element is {}", third), None => println!("There is no third element"), } // not...
true
74ae0b4c14894e2edc3cd80177f4b2db75bab624
Rust
thea0032/resourcetext
/src/object/component.rs
UTF-8
5,527
3
3
[]
no_license
use crate::component::ComponentDict; use crate::component::ComponentID; use crate::{component::RecipeID, object::Object, resources::ResourceID, ui::io::ansi}; impl Object { pub fn install_components(&mut self, id: ComponentID, cmp: &ComponentDict, amt: usize) -> usize { let component = cmp.get(id); //Gets ...
true
54acbed5336399ecdb2063e6d58c5def1633d832
Rust
dusxmt/trs80m1-mltl
/src/packing.rs
UTF-8
6,534
2.84375
3
[ "ISC" ]
permissive
// Copyright (c) 2017 Marek Benc <dusxmt@gmx.com> // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTH...
true
e63537e9ce0106f0675bc7bb891cbf34885010d0
Rust
Nugine/heng-rs
/heng-utils/src/math.rs
UTF-8
146
2.703125
3
[]
no_license
pub fn roundup_div(lhs: u64, rhs: u64) -> u64 { let ret = lhs / rhs; if lhs % rhs == 0 { ret } else { ret + 1 } }
true
54d3e4e6da143aec3c90f573ba7b37e95895b1e5
Rust
gwenn/rustyline
/src/test/emacs.rs
UTF-8
7,886
2.765625
3
[ "MIT" ]
permissive
//! Emacs specific key bindings use super::{assert_cursor, assert_history}; use config::EditMode; use keys::KeyPress; #[test] fn ctrl_a() { assert_cursor( EditMode::Emacs, ("Hi", ""), &[KeyPress::Ctrl('A'), KeyPress::Enter], ("", "Hi"), ); } #[test] fn ctrl_e() { assert_cur...
true
1a74df32062f39beadcc40ae96beb8648438cf8c
Rust
parkerziegler/rust-book
/generics/src/main.rs
UTF-8
1,943
3.984375
4
[]
no_license
fn largest<T: PartialOrd + Copy>(list: &[T]) -> T { let mut largest = list[0]; for &num in list { if num > largest { largest = num; } } largest } fn largest_return_reference<T: PartialOrd>(list: &[T]) -> &T { let mut largest = &list[0]; for num in list { i...
true
50d29d658c5f176638dfd6bb75eca97b06002b20
Rust
bernardolins/plankton
/src/container/status.rs
UTF-8
988
3.484375
3
[]
no_license
use std::fmt; use serde::Deserialize; use serde::Serialize; #[derive(PartialEq, Serialize, Deserialize)] pub enum Status { Creating, Created, Running, Stopped, } impl fmt::Debug for Status { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let status = match *self { S...
true
089d33a243ce3932f1db3508397ea20fcc9f7f68
Rust
vmiklos/osm-gimmisn
/src/yattag.rs
UTF-8
3,516
3.34375
3
[ "BSD-3-Clause", "MIT", "Unicode-DFS-2016", "CC0-1.0", "Apache-2.0", "BSD-2-Clause" ]
permissive
/* * Copyright 2021 Miklos Vajna * * SPDX-License-Identifier: MIT */ #![deny(warnings)] #![warn(clippy::all)] #![warn(missing_docs)] //! Generate HTML with Rust. //! //! This is more or less a Rust port of <https://www.yattag.org/>, mostly because //! <https://crates.io/crates/html-builder> would require you to m...
true
acf79b1bb73370b584cb1e8762f7ec31f5b38053
Rust
timonv/lax
/src/channel.rs
UTF-8
1,165
3.515625
4
[ "MIT" ]
permissive
use rustc_serialize::json::{self, DecoderError}; #[derive(RustcDecodable, Clone, Debug, PartialEq, Eq)] pub struct Channel { pub id: String, pub name: String, pub members: Option<Vec<String>>, //wth can be missing? pub is_member: bool, pub is_general: bool } pub fn new_from_str(json: &str) -> Resu...
true
1300c01568523d4234b1c21c89229d80c6231c63
Rust
EwoutH/dbus-native
/src/message.rs
UTF-8
12,431
3.171875
3
[ "Apache-2.0", "MIT" ]
permissive
//! https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling use byteorder::{LittleEndian, BigEndian, ReadBytesExt, ByteOrder, WriteBytesExt}; use crate::names::{BusName, InterfaceName, ErrorName, MemberName}; use crate::writer::{DbusWriter, DbusWrite}; use crate::reader::{DbusReader, DbusR...
true
57ec86c731e55086bf1235e17ea82c775ae1ff8a
Rust
taiki-e/tarpc
/tarpc/src/context.rs
UTF-8
3,760
2.578125
3
[ "MIT" ]
permissive
// Copyright 2018 Google LLC // // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. //! Provides a request context that carries a deadline and trace context. This context is sent from //! client to server and is used by t...
true
6210bcebd309e618b6318c5305c2a9d96c5df5ef
Rust
devas123/rust-sandbox
/shortest-bridge/src/main.rs
UTF-8
5,937
3.078125
3
[]
no_license
use std::cmp::Ordering; use std::collections::{BinaryHeap, LinkedList}; use std::mem::replace; fn main() { println!("{}", shortest_bridge(vec![vec![0, 1], vec![1, 0]])); println!("{}", shortest_bridge(vec![vec![1, 1, 1, 1, 1], vec![1, 0, 0, 0, 1], vec![1, 0, 1, 0, 1], vec![1, 0, 0, 0, 1], vec![1, 1, 1, 1, 1]])...
true
30c81e6fc4b12f418793dc6846bb1b1b12e84e66
Rust
richardwesthaver/demon
/sys/core/macros/expand.rs
UTF-8
2,024
2.53125
3
[]
no_license
use proc_macro2::TokenStream; use quote::quote; use syn::punctuated::Punctuated; use syn::{parse_quote, Error, ItemFn, Result}; #[derive(Copy, Clone, PartialEq)] pub enum Mode { Main, Test, // CompatTest, } pub fn expand(mode: Mode, mut function: ItemFn) -> Result<TokenStream> { if function.sig.inputs.len(...
true
965960dd1342d8d877795250daf7b498d8fbe479
Rust
ndouglas/azymus
/src/tile/mod.rs
UTF-8
888
3.203125
3
[ "Unlicense" ]
permissive
use crate::component; use component::renderable::{Renderable, Factory as RenderableFactory}; /// The tiles that form the map and structure of the game world. #[derive(Clone, Debug)] pub struct Tile { /// Indicates how the given object is rendered on a map. pub renderable: Renderable, /// Whether this objec...
true
b1676af3d91ce5373fb5f9312f929da78e8c4585
Rust
leriou/leetcoding
/701_800/747_largest_number_at_lest_twice_of_others/Solution.rs
UTF-8
475
2.890625
3
[]
no_license
impl Solution { pub fn dominant_index(nums: Vec<i32>) -> i32 { let mut max = -1; let mut sec = -1; let mut idx: i32 = -1; for (i, n) in nums.iter().enumerate() { if *n > max { sec = max; max = *n; idx = i as i32; ...
true
ee30f5c193ada5f4ce20eb0573b0acabec24ba52
Rust
Nitrokey/trussed-secrets-app
/src/calculate.rs
UTF-8
3,889
2.546875
3
[ "MIT", "Apache-2.0", "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (C) 2021-2022 The Trussed Developers // Copyright (C) 2023 Nitrokey GmbH // // SPDX-License-Identifier: Apache-2.0 OR MIT use core::convert::TryInto; use iso7816::Status; use crate::oath; use crate::Result; use trussed::types::Signature; use trussed::{ client, try_syscall, types::{KeyId, Location...
true
0a89056ac95218b5e5f9f58af35a963f9b85cdae
Rust
romand/payments
/src/amount.rs
UTF-8
5,454
3.265625
3
[]
no_license
#[cfg(test)] use quickcheck::{Arbitrary, Gen}; use serde::{Serialize, Serializer}; use std::error::Error; use std::fmt::{self, Display}; use std::num::ParseIntError; use std::str::FromStr; // to avoid floating point arithmetics we represent amounts as int // number of «minimal representable amount»s — 0.0001 type Mon...
true
3fa3e023fdfa29ebfe4a2e579d4b484456ea7f0a
Rust
Mubelotix/game
/src/button.rs
UTF-8
2,879
2.953125
3
[]
no_license
use std::cell::RefCell; use wasm_bindgen::JsValue; use wasm_game_lib::graphics::canvas::*; use wasm_game_lib::graphics::color::*; use wasm_game_lib::graphics::drawable::*; use wasm_game_lib::graphics::font::*; use wasm_game_lib::graphics::text::*; use wasm_game_lib::inputs::mouse::{get_mouse_position, is_mouse_pressed}...
true
9ff71410544a6282f2fc3096bc9ec4bb9fefb927
Rust
Pineapplebun/the-rust-programming-language-book
/ch8/exercises/src/statistics.rs
UTF-8
1,439
3.5
4
[]
no_license
use std::cmp::Ordering; use std::collections::HashMap; use std::str::FromStr; use std::vec::Vec; pub fn average(numbers: &Vec<f64>) -> f64 { let mut sum: f64 = 0.0; for n in numbers { sum += n } sum / (numbers.len() as f64) } pub fn median(numbers: &Vec<f64>) -> f64 { let mut sorted = numb...
true
52d88410255e411c302efd9be2c22116d73fe42d
Rust
yTakkar/fun-with-rust
/basics/src/main.rs
UTF-8
2,812
4.34375
4
[]
no_license
fn main() { let immutable = 10; println!("The value of immutable is {}", immutable); let mut mutable = 5; println!("The value of mutable is {}", mutable); mutable = 6; println!("The value of mutable is {}", mutable); // Boolean let b: bool = true; println!("Boolean: {}", b); ...
true
b5c64b43b4b9857c32a6cf95f24c9fa3ff8b3d21
Rust
ferhatgec/r
/src/main.rs
UTF-8
1,681
2.515625
3
[ "MIT" ]
permissive
// MIT License // // Copyright (c) 2021 Ferhat Geçdoğan All Rights Reserved. // Distributed under the terms of the MIT License. // // mod r { use { std::env::{var}, uptic::{Uptic} }; fn process(data: &Uptic) -> String { let (d, h, m) = (if data.days != 0 { format!("\x1b...
true
ff769388ed3266921342a50c8f3a3b93ef74238c
Rust
akolybelnikov/algorithmic-toolbox
/src/bin/maximum_ad_revenue.rs
UTF-8
2,821
3.46875
3
[]
no_license
use std::io; use std::io::{BufRead}; fn max_dot_product(n:usize, a: &mut Vec<i64>, b: &mut Vec<i64>) -> i64 { let mut r = 0; if a.len() == 0 || b.len() == 0 {return r;} if a.len() != n || b.len() != n {return r;} a.sort(); b.sort(); for i in 0..n { r += a[i] * b[i]; } return r; ...
true
42f0f75021981ace398dd4a42e0a0fe00cebe417
Rust
tc21/advent-of-code-2020
/src/bin/13-shuttle-search/main.rs
UTF-8
3,789
3.21875
3
[]
no_license
/* --- Day 13: Shuttle Search --- Your ferry can make it safely to a nearby port, but it won't get much further. When you call to book another ship, you discover that no ships embark from that port to your vacation island. You'll need to get from the port to the nearest airport. Fortunately, a shuttle bus service is ...
true
d66e9807f0d925856e0c9091a463c4d68cb5e028
Rust
Janonard/arrdf
/src/turtle.rs
UTF-8
1,411
2.84375
3
[]
no_license
use nom::branch::*; use nom::bytes::streaming::*; use nom::character::streaming::*; use nom::combinator::*; use nom::multi::*; use nom::sequence::*; use nom::*; use std::convert::TryFrom; #[derive(Debug)] enum FromHexError { ToCharError, ToU32Error, } fn from_hex(input: &str) -> Result<char, FromHexError> { ...
true
3ad3918d7e047a4472184d916b0ae4f1078a836a
Rust
chalme/coco
/src/infrastructure/git/git_commit_message.rs
UTF-8
1,700
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::domain::git::coco_commit_message::ConventionalMessage; use regex::Regex; lazy_static! { static ref CONVENTIONAL: Regex = Regex::new( r"(?x)(?P<type>build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test) # type (?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)? # scope :\s? (?P<subject>.*)?...
true
7c62212b8db95cdd7f36385918f751ae380fb483
Rust
serbe/anet
/src/errors.rs
UTF-8
4,233
2.59375
3
[ "MIT" ]
permissive
use std::{io, net, result, string}; use thiserror::Error; pub type Result<T> = result::Result<T, Error>; #[derive(Error, Debug)] pub enum Error { #[error("Socks version: {0} not supported")] NotSupportedSocksVersion(u8), #[error("Version: {0} not supported")] NotSupportedVersion(u8), #[error("io ...
true
ee8f925693d4160204b0187a852cb2a0f2b49c5f
Rust
dawsongzhao/prusto
/src/types/mod.rs
UTF-8
15,491
2.71875
3
[ "MIT" ]
permissive
mod boolean; mod data_set; mod date_time; mod decimal; mod fixed_char; mod float; mod integer; mod interval_day_to_second; mod interval_year_to_month; mod ip_address; mod map; mod option; mod row; mod seq; mod string; pub(self) mod util; pub mod uuid; pub use self::uuid::*; pub use boolean::*; pub use data_set::*; pub...
true
b48bd492bc59dc1e5102d536ef819cbadaccbc31
Rust
Keats/jsonwebtoken
/src/crypto/ecdsa.rs
UTF-8
1,422
2.59375
3
[ "MIT" ]
permissive
use ring::{rand, signature}; use crate::algorithms::Algorithm; use crate::errors::Result; use crate::serialization::b64_encode; /// Only used internally when validating EC, to map from our enum to the Ring EcdsaVerificationAlgorithm structs. pub(crate) fn alg_to_ec_verification( alg: Algorithm, ) -> &'static sign...
true
adb9b167c347870ab3a8091d98f08f2257b579c2
Rust
wangzk1900/kvs
/src/lib.rs
UTF-8
1,179
3.9375
4
[]
no_license
#![deny(missing_docs)] //! # KvStore //! //! A library for storing key/values. use std::collections::HashMap; /// The `KvStore` stores key/values in memory. /// /// Example: /// /// ```rust /// # use kvs::KvStore; /// let mut store = KvStore::new(); /// store.set("key".to_owned(), "value".to_owned()); /// let val = ...
true
1eeb1fe0b86946a12ad2081f1874ba562bf40c82
Rust
mengsuenyan/rmath
/src/rand/crypto_rand.rs
UTF-8
2,060
2.734375
3
[ "Apache-2.0" ]
permissive
use std::marker::PhantomData; use crate::rand::{Seed, PrimitiveType, Result, RandErrKind, RandError, Source}; #[cfg(target_os = "windows")] use crate::os::windows::bcrypt::{BCrypt, AlgorithmHandle, CNGAlgorithmIdentifier, AlgorithmHandleFlag}; #[cfg(target_os = "linux")] use crate::os::linux::BCrypt; #[derive(Clone)]...
true
300d5a008b4ac30bd0034d1aac1c27aa3b6b8177
Rust
richardwesthaver/demon
/sys/core/macros/lib.rs
UTF-8
1,231
2.5625
3
[]
no_license
mod expand; use expand::{expand, Mode}; use proc_macro::TokenStream; use syn::parse::Nothing; use syn::parse_macro_input; /// Expands from: /// /// #[demon_core::main] /// fn main(dm: DemonInit) { /// ... /// } /// /// to: /// /// fn main() { /// let dm: DemonInit = demon_core::r#impl::perform_init(); /// ... /// ...
true
3c29dceeec066b6e454ea67dcb6315f727844393
Rust
littleroys/leetcode-rs
/src/string/reverse_str.rs
UTF-8
367
3.5625
4
[]
no_license
// #344 reverse string struct Solution; impl Solution { pub fn reverse_string(s: &mut Vec<char>) { s.reverse(); } } #[cfg(test)] mod test { use crate::string::reverse_str::Solution; #[test] pub fn test() { let mut s = vec!['h', 'e', 'l', 'l', 'o']; Solution::reverse_string...
true
174ecbae0c213e1838726a55e4567163639c112a
Rust
JScearcy/rust-faux-repl
/src/code/mod.rs
UTF-8
525
3.65625
4
[]
no_license
pub struct Code { code: Vec<String>, } impl Default for Code { fn default() -> Code { Code { code: Vec::new(), } } } impl Code { pub fn new() -> Code { Code::default() } pub fn get(&self) -> String { self.code.join("") } // fn set(&mut self...
true
63b51fd8bf7e6ed8eef3bf444c55219dd93d0cc2
Rust
checkman123/parser-with-Rust
/src/main.rs
UTF-8
11,022
3.4375
3
[]
no_license
use std::env; use std::fs::File; use std::io::prelude::*; /* Character classes */ const LETTER: i32 = 0; const DIGIT: i32 = 1; const UNKNOWN: i32 = 99; /* Token codes */ const ID: i32 = 10; const ASSIGN: i32 = 11; const POINT: i32 = 12; const LPAREN: i32 = 13; const RPAREN: i32 = 14; const NUM: i32 = 15; cons...
true
9fa853dfdeb8d9be19eb3b5009527ac4103d8139
Rust
yuulive/bo
/examples/reader.rs
UTF-8
2,022
3.015625
3
[ "MIT" ]
permissive
extern crate bo; use bo::Reader; use std::vec::Vec; #[derive(Debug)] struct User { id: i32, some_val: i32, } #[derive(Debug,Clone)] struct KV { //state: Box<i32>, state: i32, } impl KV { fn get(&self, space: &str, key: i32) -> i32 { key * 2 } } #[derive(Debug,Clone)] struct GraphD...
true
4fa69bc3be8227f945ab93c4f94d740530546ba4
Rust
FORGIS98/money-split-manager
/src/database.rs
UTF-8
2,267
3.28125
3
[]
no_license
use rusqlite::{params, Connection, Result}; #[derive(Debug)] struct Receipt { id: i32, payer: String, amount: f32, description: String, } #[derive(Debug)] struct Ledger { id: i32, borrower: String, amount: f32, owner: String, } /// Creates two tables, **receipt** to save all the expen...
true
dc75c7f0859490893886e2a971d9acd589db4b9c
Rust
reb/advent_of_code_2018
/src/day_06.rs
UTF-8
11,277
4.0625
4
[]
no_license
/// --- Day 6: Chronal Coordinates --- /// /// The device on your wrist beeps several times, and once again you feel like /// you're falling. /// /// "Situation critical," the device announces. "Destination indeterminate. /// Chronal interference detected. Please specify new target coordinates." /// /// The device then...
true
9110e6d6d723e599a20ec3ee1295af7af397e936
Rust
kwsm114514/typical90
/MyAnswers/ans018.rs
UTF-8
685
3.03125
3
[]
no_license
use proconio::{input, fastout}; use std::f64::consts::PI; const RAD_TO_DEG: f64 = std::f64::consts::FRAC_1_PI * 180.0; #[fastout] fn main() { input!{t: f64, l: f64, x: f64, y: f64, q: usize, times: [f64; q]} // (y, z) let position = |time: f64| -> (f64, f64) { let y: f64 = - (l / 2.0) * (2.0 * PI...
true
d88d3f4c7ad7eaf7d58e53523cd99bc1d6b18e94
Rust
sohardforaname/SimpleRustLuaJIT
/src/codegen/sym_tb/sym_tb.rs
UTF-8
629
2.828125
3
[]
no_license
use std::collections::{HashMap, HashSet}; use crate::ast::lexer::token::Token; use std::borrow::Borrow; struct SymbolTable { scope_index: HashMap<Token, Vec<usize>>, token_stack: Vec<HashSet<Token>>, } impl SymbolTable { /*pub fn new() -> SymbolTable { SymbolTable { scope_index: HashMa...
true
b8eeb4ef36495b92543c6aa8f81b05a09be22923
Rust
zerovolts/wasmuter
/src/main.rs
UTF-8
3,104
2.734375
3
[ "MIT" ]
permissive
use std::{fs::File, io, io::prelude::*}; use crate::{ encoder::{WasmEncode, WasmEncoder}, expression::{Expression, Instruction, MemoryArguments}, function_type::{FunctionType, ValueType}, index::{FunctionIndex, MemoryIndex, TypeIndex}, limits::Limits, module::Module, section::{ code...
true
fe3ead4264ece6a9a8f367b41aa547e0981f7c16
Rust
tensorbase/tensorbase
/crates/arrow/src/array/array_struct.rs
UTF-8
18,573
2.734375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
fc348ec8039a2201c2ca8221a7478cf8a4b07146
Rust
superfly/accept-encoding
/src/error.rs
UTF-8
966
3.28125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::result; /// A specialized [`Result`] type for this crate's operations. /// /// This is generally used to avoid writing out [Error] directly and /// is otherwise a direct mapping to [`Result`]. /// /// [`Result`]: https://doc.rust-lang.org/nightly/std/result/enum.Result.html /// [`Error`]: std.struct.Error.htm...
true
a822fb3fa878bd1fca3cfba2b7d1cceb16090634
Rust
christheblog/graph-commands
/core/src/format/utils.rs
UTF-8
1,471
3.203125
3
[]
no_license
//! Module providing helper to read/write to graph files use crate::directed_graph::DirectedGraph; use crate::graph_command::GraphCommand; use std::fs::File; use std::io::{BufRead, BufReader}; /// /// Reading Graph files /// /// Reads a file into a DirectedGraph pub fn read<ParseFn, IsCommentFn>( file: File, ...
true
88d0b382e4231041dab55b421769c59c7074645f
Rust
bottine/nem
/darts_and_maps/src/lib.rs
UTF-8
43,810
2.953125
3
[]
no_license
#![feature(map_first_last)] pub mod darts { use auto_ops::impl_op_ex; // to define multiplication use bit_set::BitSet; use gcd::Gcd; use rand::seq::SliceRandom; use rand::Rng; use std::collections::BTreeSet; use std::fmt; /* CONSTANTS SET BY HAND */ pub type PermBitRep = u128; ...
true
0b4c95e9aa9128f810b9d7b9c7655fcd523d8943
Rust
linyinfeng/rspg
/rspg/src/lr0/item.rs
UTF-8
6,172
3.453125
3
[ "MIT" ]
permissive
use crate::display::DisplayWith; use crate::grammar::Grammar; use crate::grammar::RuleIndex; use crate::grammar::Symbol; use serde::Deserialize; use serde::Serialize; use std::cmp::Ordering; use std::fmt; #[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Clone, Copy)] pub struct Item { ...
true
0402e12ef0b81f7bea5ac9538a1477ea5a781c9f
Rust
m-dahl/hello-rust
/src/test.rs
UTF-8
3,229
3.046875
3
[]
no_license
use uuid::Uuid; use serde::{Serialize, Deserialize, }; use std::collections::HashMap; #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] enum Predicate { AND(Vec<Predicate>), OR(Vec<Predicate>), Not(Box<Predicate>), TRUE, FALSE, EQ(SPValue, SPValue), // use SPValue::ID to fetch the v...
true
3a977f35a189f0da188b5f9f99105a54c6786c64
Rust
woelper/parallel-getter
/src/range.rs
UTF-8
3,065
3.375
3
[ "MIT" ]
permissive
use numtoa::NumToA; use reqwest::header::HeaderValue; use std::io; pub(crate) fn calc_range(length: u64, nthreads: u64, part: u64) -> Option<(u64, u64)> { if length == 0 || nthreads == 1 { None } else { let section = length / nthreads; let from = part * section; let to = if par...
true
8cfe5bb57c1cde21ab92c0d8f938b1cb6b6eb584
Rust
Xi4UWI84dRNrG9kQj5OP/YFT
/src/yft40sn_bin_fnv.rs
UTF-8
21,101
2.859375
3
[ "MIT" ]
permissive
extern crate fnv; use args::Args; use log::Log; use uint::u40; use self::fnv::FnvHashMap; use predecessor_set::PredecessorSet; pub type DataType = u40; const BIT_LENGTH: usize = 40; /*If v is a node at a height j, then all the leafs descending from v will have key values between the quantities (i - 1)2^J + 1 and i*...
true
04c0d43b2066b13852bca8bb463cd8107b268bfd
Rust
TheZalli/rectdraw
/examples/ansi_escape.rs
UTF-8
185
2.921875
3
[]
no_license
fn main() { // reset print!("\x1Bc"); // try color and other styles println!("\x1B[38;2;241;112;105mHello \x1B[7mWorld!"); // change title print!("\x1B]0;Hello Title!\x1B\\"); }
true
46b3a93f82eda349be3bdfc4ac2f311428264a9c
Rust
razielgn/ostrov
/tests/eval_assignment.rs
UTF-8
1,330
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::helpers::{values::*, *}; use ostrov::errors::RuntimeError::*; #[test] fn returns_expression() { assert_eval_val( "(define x 0) (set! x (+ x 1))", unspecified(), ); } #[test] fn overwrites_variables() { assert_eval( "(define x 0) (set! x (+ x 1)) ...
true
c6998bc94b97946f5c91767546cbe3dafd09aa38
Rust
ccqpein/Arithmetic-Exercises
/double-link-list/DLL.rs
UTF-8
2,022
3.484375
3
[ "Apache-2.0" ]
permissive
use std::rc::Rc; #[derive(Debug)] struct DLList<T> { Node: T, Prev: Option<Rc<DLList<T>>>, Next: Option<Rc<DLList<T>>>, } impl<T: Copy> DLList<T> { fn new(val: T) -> Self { DLList { Node: val, Prev: None, Next: None, } } fn cons(val: T, li: ...
true
4f0eb91eb40a1e69132a964c1913b6c126c70371
Rust
newsboat/newsboat
/rust/libnewsboat-ffi/src/fmtstrformatter.rs
UTF-8
917
2.59375
3
[ "MIT", "CC-BY-4.0" ]
permissive
use libnewsboat::fmtstrformatter; // cxx doesn't allow to share types from other crates, so we have to wrap it // cf. https://github.com/dtolnay/cxx/issues/496 struct FmtStrFormatter(fmtstrformatter::FmtStrFormatter); #[cxx::bridge(namespace = "newsboat::fmtstrformatter::bridged")] mod bridged { extern "Rust" { ...
true
e532a55e4fabc378a84074073077c4057f28b800
Rust
guydunton/rust-gb
/src/debug_cli/widgets/memory_widget.rs
UTF-8
1,285
3.0625
3
[]
no_license
#![allow(clippy::needless_return)] use super::super::layout::Print; use crate::gameboy::Gameboy; pub struct MemoryWidget<'a> { gb: &'a Gameboy<'a>, start: u16, } impl<'a> MemoryWidget<'a> { pub fn new(gb: &'a Gameboy, start: u16) -> MemoryWidget<'a> { MemoryWidget { gb, start } } } impl<'a> P...
true
00233c3f14740ce663ac2f1a28fc17e542bb6aea
Rust
lin20121221/Yazz
/src/tui/controller.rs
UTF-8
885
2.953125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; use std::cmp::Eq; use std::hash::Hash; use super::{MouseMessage, Observer, Value}; pub struct Controller<Key: Copy + Eq + Hash> { pub observers: HashMap<Key, Rc<RefCell<dyn Observer>>>, } impl<Key: Copy + Eq + Hash> Controller<Key> { pub...
true
73a1d702478a54fcb6428212bc08a9a7ef1ba53a
Rust
dragon1061/MoonZoon
/crates/moon/src/frontend.rs
UTF-8
3,267
2.796875
3
[ "MIT" ]
permissive
use crate::CONFIG; use std::borrow::Cow; use tokio::fs; pub struct Frontend { pub(crate) title: String, pub(crate) default_styles: bool, pub(crate) append_to_head: String, pub(crate) body_content: Cow<'static, str>, } impl Default for Frontend { fn default() -> Self { Self { ti...
true
7bc076d6ffe23e13ec22dda1daacc24d1b06553a
Rust
mikelodder7/keychain-services.rs
/src/keychain/key/algorithm.rs
UTF-8
17,939
2.53125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use crate::ffi::*; use core_foundation::{base::TCFType, string::CFString}; /// Cryptographic algorithms for use with keys stored in the keychain. /// /// Wrapper for `SecKeyAlgorithm`. See: /// <https://developer.apple.com/documentation/security/seckeyalgorithm> #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Ke...
true
39bc87439b8237427ef3a408b3234649a492e25a
Rust
Jcrash29/AdventOfCode
/2018_rust/Advent_2018_day_1/src/main.rs
UTF-8
1,547
3.640625
4
[]
no_license
use std::io::{BufReader, BufRead}; use std::fs::File; fn main() { println!("Hello, world!"); let array = read("temp.txt").unwrap(); //println!("{:?}", array); let result = get_total(&array); println!("The Resulting Frequnecy is {}",result); let result = get_first_repeate(&ar...
true
3024d67a7fa3967e67fb335b1e0a79ce9f5764a0
Rust
go717franciswang/exercism
/rust/alphametics/src/lib.rs
UTF-8
3,661
3.34375
3
[]
no_license
use std::collections::HashMap; use std::collections::BTreeSet; #[derive(Debug)] struct Equation { left: HashMap<char, u32>, right: HashMap<char, u32>, leading_tokens: BTreeSet<char> } impl Equation { fn new(puzzle: &str) -> Self { let sides = puzzle.split(" == ").collect::<Vec<&str>>(); ...
true
214bac7535e7deed57e83ede04f56495a3c0199e
Rust
kvart2006/sycamore
/packages/sycamore-macro/src/view/component.rs
UTF-8
2,854
2.765625
3
[ "MIT" ]
permissive
use std::mem; use proc_macro2::TokenStream; use quote::{quote, quote_spanned, ToTokens}; use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::token::{Comma, Paren}; use syn::{parenthesized, parse_quote, Expr, GenericArgument, Path, Result}; /// Components are iden...
true
9b0937420bda820b4276b6c1c45fbc17e1ab120c
Rust
dennisss/dacha
/pkg/raft/src/routing/route_channel.rs
UTF-8
2,021
2.515625
3
[ "Apache-2.0" ]
permissive
use std::collections::HashSet; use std::sync::Arc; use common::errors::*; use crate::proto::ident::*; use crate::proto::server_metadata::GroupId; use crate::routing::route_resolver::RouteResolver; use crate::routing::route_store::RouteStore; use crate::server::channel_factory::ChannelFactory; pub struct RouteChannel...
true
80b7acfdbc812e9264a6c8beb166c1dfb358e056
Rust
Tembocs/rome
/crates/rome_console/src/fmt.rs
UTF-8
10,222
3.140625
3
[ "MIT" ]
permissive
use std::{ borrow::Cow, fmt::{self, Write as _}, io, time::Duration, }; use termcolor::{ColorSpec, WriteColor}; use unicode_width::UnicodeWidthChar; use crate::{markup, Markup, MarkupElement}; /// A stack-allocated linked-list of [MarkupElement] slices pub enum MarkupElements<'a> { Root, Node...
true
ea3ea9157b585174689fe50b48c6e4efcb068b50
Rust
ars-dev-br/fundamentals
/bloom-rust/src/main.rs
UTF-8
435
2.96875
3
[]
no_license
mod bloom; fn main() { let mut bloom: bloom::Bloom<u32> = bloom::Bloom::new(5000, 7); bloom::add(&mut bloom, &1); bloom::add(&mut bloom, &2); bloom::add(&mut bloom, &3); let queries = 1000; let mut positives = 0; for i in 0..queries { positives += if bloom::query(&bloom, &i) { 1 ...
true
b7aa6d470d58629426107309e4a6debe39b92b59
Rust
yhakbar/ya
/tests/yadayada-template.rs
UTF-8
4,068
2.8125
3
[ "MIT" ]
permissive
#[cfg(test)] mod template { use anyhow::Result; use assert_cmd::Command; use tempfile::tempdir; fn yadayada() -> Command { Command::cargo_bin("yadayada").expect("Error invoking yadayada") } #[test] fn list() -> Result<()> { let tmp = tempdir()?; let templates_dir =...
true
e3d45e1ae367240339fc1357f692bd9b840b122e
Rust
pchickey/cap-std
/cap-primitives/src/fs/manually/read_link_one.rs
UTF-8
1,095
2.765625
3
[ "MIT", "LLVM-exception", "Apache-2.0" ]
permissive
use crate::fs::{errors, read_link_unchecked, MAX_SYMLINK_EXPANSIONS}; use std::{ ffi::OsStr, fs, io, path::{Path, PathBuf}, }; /// This is a wrapper around `read_link_unchecked` which performs a single /// symlink expansion on a single path component, and which enforces the /// recursion limit. pub(super) ...
true
dfe547c43551a4bf9ad24d3604ba4965c6fa3e04
Rust
drbrain/AOC
/2020/src/bin/day_5.rs
UTF-8
3,669
3.421875
3
[]
no_license
use anyhow::Result; use aoc2020::read; use std::cmp::Ordering::Equal; use std::cmp::Ordering::Greater; use std::cmp::Ordering::Less; fn main() -> Result<()> { let input = read("./05.input")?; println!("part A: {}", day_5_a(&input)); println!("part B: {}", day_5_b(&input)); Ok(()) } fn day_5_a(inpu...
true
4bd6d9bcaac4d6f747fe302c10d53df36930a3c8
Rust
lucasig11/jlox
/src/lib/interpreter/util.rs
UTF-8
1,512
3.234375
3
[]
no_license
macro_rules! check { ($test:expr, $($val:expr),+) => { { let mut check = true; $( if !$test($val) { check = false; } )+ check } }; } /// Test each val, if the test returns false, returns an Error...
true
22f507996ab1ecc6e0fe7ec7836d9ad3925e165a
Rust
qezz/rustube
/src/descrambler/mod.rs
UTF-8
8,715
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::sync::Arc; use reqwest::Client; use url::Url; use cipher::Cipher; use crate::{IdBuf, Stream, Video, VideoDetails, VideoInfo}; use crate::error::Error; use crate::video_info::player_response::streaming_data::RawFormat; use crate::video_info::player_response::streaming_data::StreamingData; mod cipher; /// A...
true
573c4a4ac2381afb7997b0b6e72f65174a078f0c
Rust
a544jh/my-rusty-sensors
/src/gateway/serial.rs
UTF-8
6,091
2.90625
3
[]
no_license
use super::message; use bufstream::BufStream; use serialport::SerialPort; use std; use std::io::BufRead; use std::io::Write; pub struct SerialGateway { buf: BufStream<Box<SerialPort>>, } impl SerialGateway { pub fn new(port: Box<SerialPort>) -> SerialGateway { SerialGateway { buf: BufStrea...
true
a96f920b0d0ce6c10dbadf7eb93a319120256235
Rust
antoyo/relm
/relm-examples/examples/7gui/5_crud/src/gui/person_list_box.rs
UTF-8
4,253
3.265625
3
[ "MIT" ]
permissive
use crate::gui::win::WinMsg; use crate::model::{Person, PersonList}; use gtk::prelude::*; use gtk::Label; use relm::{Relm, StreamHandle, Widget}; use relm_derive::{widget, Msg}; #[derive(Msg)] pub enum PersonListBoxMsg { AddPerson(Person), DeleteSelected, UpdateSelected(Person), Filter(String), Se...
true
60b0c51747d8ebb7fc08ce74b8574e7b6f356d9a
Rust
mrbass21/NetflixRatingsExporter
/src/lib.rs
UTF-8
3,732
3.65625
4
[]
no_license
use std::error::Error; #[derive(PartialEq, Debug)] pub enum ConfigResult <E>{ HelpMenu, Ok, Err(E), } #[derive(PartialEq, Debug)] pub enum MovieFilter { None, IgnoreRemoved, } #[derive(PartialEq, Debug)] pub struct Config { pub movie_filter: MovieFilter, pub session_token: Option<String>...
true
0b272eaa6d38cfff7edb118cc80780fd5820fdb4
Rust
saskenuba/SteamHelper-rs
/crates/tappet-derive/src/lib.rs
UTF-8
6,823
2.640625
3
[ "MIT" ]
permissive
use proc_macro::TokenStream; use proc_macro2::Span; use quote::quote; use syn::punctuated::Punctuated; use syn::{parse_macro_input, Data, DeriveInput, Field, Fields, Ident, Meta}; const META_COMMA: &str = "comma"; const META_INDEXED: &str = "indexed"; /// To retrieve the original name of the endpoint, we subtract th...
true
ad4031fbb80b1d4de4c40a39a8c3ed60f0aceff2
Rust
preston-evans98/zebra
/zebra-network/src/protocol/external/inv.rs
UTF-8
6,948
3.34375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Inventory items for the Bitcoin protocol. // XXX the exact optimal arrangement of all of these parts is a little unclear // until we have more pieces in place the optimal global arrangement of items is // a little unclear. use std::io::{Read, Write}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; u...
true
1e6f5c99a4e25e7a0cf9ddd90e561b07821514cd
Rust
IThawk/rust-project
/rust-master/src/test/ui/consts/const-eval/double_check2.rs
UTF-8
321
2.59375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
enum Foo { A = 5, B = 42, } enum Bar { C = 42, D = 99, } #[repr(C)] union Union { foo: &'static Foo, bar: &'static Bar, u8: &'static u8, } static BAR: u8 = 5; static FOO: (&Foo, &Bar) = unsafe {( //~ undefined behavior Union { u8: &BAR }.foo, Union { u8: &BAR }.bar, )}; fn main() {}...
true
1e28e14af714fdf353774dc41ec1bbfaf0503a86
Rust
Restioson/tale_of_an_arts_major
/src/entity/components.rs
UTF-8
2,562
3.171875
3
[ "Apache-2.0" ]
permissive
use ggez::graphics::{self, Image, Rect}; use specs::{Component, HashMapStorage, VecStorage, World}; /// Registers all the components from this module to the given world pub fn register_components(world: &mut World) { world.register::<Player>(); world.register::<Sprite>(); world.register::<Directional>(); ...
true
8ae4ea379135133ebd68950ec22cd786a3410049
Rust
AlecGoncharow/aoc-2020
/day-2/src/main.rs
UTF-8
2,106
3.625
4
[]
no_license
use std::fs::File; use std::io::prelude::*; #[derive(Debug)] struct Policy { min: u8, max: u8, letter: char, } impl From<&str> for Policy { fn from(s: &str) -> Self { let mut split = s.split_whitespace(); let mut num_split = split.next().unwrap().split('-'); let letter = split...
true
c6c4ff69a19bf0c8d3cd6e52a13f228e4a67ed42
Rust
sheredom/AOC2020
/src/day07/mod.rs
UTF-8
3,262
3.203125
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
use itertools::Itertools; use std::collections::HashMap; type Payload<'a> = (HashMap<&'a str, usize>, Vec<Vec<(usize, usize)>>); fn parse_data(string: &str) -> Payload { let mut inc_id = 0; let mut map = HashMap::new(); let mut vec = Vec::new(); for line in string.lines() { let (mut key, mut ...
true
ae65a7e6b11d3ad2b46ceb0d62887750ad9ba2c3
Rust
jfmcbrayer/aardwolf-models
/src/link.rs
UTF-8
3,289
2.765625
3
[]
no_license
use std::fmt; use std::io::Write; use std::str::FromStr; use std::error::Error as StdError; use diesel::backend::Backend; use diesel::Expression; use diesel::serialize; use diesel::deserialize; use diesel::sql_types::Text; use url::Url; use base_post::BasePost; use schema::links; #[derive(Clone, Copy, Debug, Eq, Has...
true
e07512a502680520e2757f4b96c1b79cec54a310
Rust
akshaysasidrn/learning_rust
/integer_processing/src/main.rs
UTF-8
1,728
3.6875
4
[]
no_license
// Problem statement: // Given a list of integers, use a vector and return the mean (the average value), // median (when sorted, the value in the middle position), // and mode (the value that occurs most often) of the list. use std::io; use std::collections::HashMap; fn main() { println!("Provide list of integers...
true
ceba96801e777fae4f436201b4cc1b041e6d4d55
Rust
danmedani/euler
/146/src/main.rs
UTF-8
1,401
3.21875
3
[]
no_license
fn main() { let mut count = 0; for i in 2..150000000 { let i_sq = i * i; if probably_prime(i_sq+1) && probably_prime(i_sq+3) && probably_prime(i_sq+7) && probably_prime(i_sq+9) && probably_prime(i_sq+13) && probably_prime(i_sq+27) { if is_prime(i_sq+1) && is_prime(i_sq+3) && ...
true
601a6140b40d7c080834e20232450810afd552ba
Rust
tommcgurl/learn-rust-live
/projects/option_match/src/main.rs
UTF-8
512
3.734375
4
[]
no_license
fn main() { let five = Some(5); let six = plus_one(five); let none = plus_one(None); println!("Six is {:?}, none is {:?}", six, none); print_only_fives(Some(1)); print_only_fives(Some(5)); print_only_fives(Some(7)); } fn plus_one(x: Option<i32>) -> Option<i32> { match x { None => None, Some(...
true
d9b8f13e71fab45ca52ad006e68e412a0724a526
Rust
Robzz/TexSyn
/libtexsyn/src/errors.rs
UTF-8
1,495
3.234375
3
[]
no_license
use image::ColorType; error_chain! { types { Error, ErrorKind, ResultExt, Result; } // Automatic conversions between this error chain and other // error chains. In this case, it will e.g. generate an // `ErrorKind` variant called `Dist` which in turn contains // the `rustup_d...
true
8c168341bb05499088fba07aaa5d2ed042eba81f
Rust
JoNil/AOC2019
/day_2_a/src/main.rs
UTF-8
2,743
3.6875
4
[]
no_license
use std::error::Error; use std::fs; enum Opcode { Add = 1, Mult = 2, Halt = 99, } impl From<i32> for Opcode { fn from(value: i32) -> Self { match value { 1 => Opcode::Add, 2 => Opcode::Mult, 99 => Opcode::Halt, _ => panic!("Unknown opcode"), ...
true
9984a4fb22cd8bf02063cb96a091c7b7b3d50978
Rust
kingli-crypto/spectral
/src/boolean.rs
UTF-8
1,753
3.359375
3
[ "Apache-2.0" ]
permissive
use super::{AssertionFailure, Spec}; pub trait BooleanAssertions { fn is_true(&mut self); fn is_false(&mut self); } impl<'s> BooleanAssertions for Spec<'s, bool> { /// Asserts that the subject is true. The subject type must be `bool`. /// /// ```rust,ignore /// assert_that(&true).is_true(); ...
true
3dcffcc564061105c87c396032b0b437e13a58af
Rust
RazrFalcon/tiny-skia
/src/shaders/mod.rs
UTF-8
4,576
2.859375
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2006 The Android Open Source Project // Copyright 2020 Yevhenii Reizner // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. mod gradient; mod linear_gradient; mod pattern; mod radial_gradient; use tiny_skia_path::{NormalizedF32, Scalar}; pub use gra...
true
14931dec9ba30a31e281758dbd310fd560e7bc35
Rust
crhino/Playing-With-Rust
/graph.rs
UTF-8
8,258
3.296875
3
[]
no_license
/* Chris Piraino * * * Implementation of a Graph and * associated algorithms and data * structures. * */ use std::vec::Vec; use std::result::Result; #[test] use std::io::stdio; pub trait Graph { fn new(vertices: uint) -> ~Self; fn adjacent(&self, x: uint, y: uint) -> Result<bool, ~str>; fn neigh...
true
2b79f50fe8d07f3c49101522ebc361f49bfd3d89
Rust
gc210797/leetcode
/src/wildcard_matching.rs
UTF-8
1,007
3.21875
3
[]
no_license
//https://leetcode.com/problems/wildcard-matching/ struct Solution; impl Solution { pub fn is_match(s: String, p: String) -> bool { let string: Vec<_> = s.chars().collect(); let pattern: Vec<_> = p.chars().collect(); let slen = string.len(); let plen = pattern.len(); ...
true
a4486bc0b8861ea4121470669e021f04ee88d4d1
Rust
dkijania/rust-bdd
/src/api/utils/context.rs
UTF-8
2,165
3.125
3
[]
no_license
use crate::api::{keys::ApiKeys, utils::env::env_has_value, Api}; use std::env::var; const API_KEY_ENV_NAME: &str = "API_KEY"; const SECRET_KEY_ENV_NAME: &str = "SECRET_KEY"; const ENDPOINT: &str = "API_ENDPOINT"; const DEBUG: &str = "DEBUG"; /// holds all necessary data for interaction with rest api #[derive(Clone, D...
true
a7379587a1f9323777a969d1f7f31204bd783d5a
Rust
jakalope/vixi
/src/normal_mode.rs
UTF-8
2,605
3.015625
3
[ "MIT" ]
permissive
use disambiguation_map::Match; use mode::*; use mode_map::MapErr; use op::NormalOp; use state::State; use typeahead::Parse; impl<K> Transition<K> for NormalMode<K> where K: Ord, K: Copy, K: Parse, { fn name(&self) -> &'static str { "Normal" } fn transition(&self, state: &mut State<K>) ...
true
d380fccc38fd6d490640eddc6dcce2995792a4ea
Rust
i10416/ods
/chapter11/src/heapsort.rs
UTF-8
1,006
3.0625
3
[ "MIT" ]
permissive
#![allow(clippy::many_single_char_names,clippy::explicit_counter_loop, clippy::redundant_closure)] use chapter10::binaryheap::BinaryHeap; pub fn heapsort<T: PartialOrd + Clone>(a: &mut [T]) { BinaryHeap::sort(a); } #[cfg(test)] mod test { use super::heapsort; use rand::distributions::Standard; use ran...
true
2a368cf6048699745fa92bc4f62b6341ed7d524b
Rust
m00ga/bot_collection_rs
/src/captcha/solvers.rs
UTF-8
4,420
2.75
3
[]
no_license
use super::{CapTypes, CapSolvable, RefCell, HashMap}; use reqwest::blocking; use serde; //extern crate serde; //extern crate serde_derive; //extern crate serde_json; pub mod re_caps{ use super::*; use std::thread::sleep; use std::time::Duration; #[derive(Debug, serde::Deserialize)] struct ReCap...
true