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
0ed5243ae7a422136a61d0b133969f7d1e390877
Rust
aylei/leetcode-rust
/src/solution/s0238_product_of_array_except_self.rs
UTF-8
1,501
3.515625
4
[ "Apache-2.0" ]
permissive
/** * [238] Product of Array Except Self * * Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. * * Example: * * * Input: [1,2,3,4] * Output: [24,12,8,6] * * * Note: Please solve it without division ...
true
06f1ce0fdc648310c63c2e5865a4a7a6f003d390
Rust
Lehona/Parsiphae
/src/parsers/base.rs
UTF-8
2,179
2.984375
3
[ "MIT" ]
permissive
use inner_errors::ParserError; use types::*; fn is_not_quote(input: u8) -> bool { input != b'\"' } fn convert_string_literal(input: Input) -> StringLiteral { StringLiteral::new(&input.0) } named!(pub string_parser<Input, StringLiteral, ParserError>, fix_error!(ParserError, map!( delimited!( tag!(...
true
4fc731ef620f8fa0ab1bb739a964d1b7ca683606
Rust
RustWorks/potw-rs-actix-web-csrf
/src/middleware/liquid.rs
UTF-8
2,320
2.890625
3
[]
no_license
use std::path::PathBuf; use std::fs::File; use std::io::Read; use actix_web::{ error::ErrorInternalServerError, Responder, HttpRequest, HttpResponse, Error, Result, http::StatusCode, middleware::{ Middleware, Response }, }; use liquid::{ Parser, ParserBuilder, Object, compiler::FilesystemInclude }; us...
true
abc96a836879a25074e7222fab7e61d7cddcc65d
Rust
Orlha/bright-red
/src/engine.rs
UTF-8
2,244
2.640625
3
[]
no_license
use std::io; use std::io::Write; use std::thread; use std::time; //use std::fmt::Write; use termion; use termion::input::TermRead; use termion::raw::IntoRawMode; use termion::raw::RawTerminal; use termion::AsyncReader; use termion::input::MouseTerminal; use crate::ext::Result; use crate::game::*; use log::{info, war...
true
6e7302927fd80e59259b902434f731f87b55ecbc
Rust
Zerthox/finite
/src/nfa.rs
UTF-8
6,807
2.875
3
[ "MIT" ]
permissive
use super::{Automaton, AutomatonError, DFA}; use serde::{Deserialize, Serialize}; use std::{ collections::{BTreeSet, HashMap, HashSet}, fmt, hash::Hash, }; #[derive(Default, Debug, Serialize, Deserialize)] #[serde(default, deny_unknown_fields)] struct State<S, I> where S: Eq + Hash, I: Eq + Hash, { accepts: bool...
true
50a391c59f003296db97c73c0a0faf7becd5116b
Rust
Rrogntudju/warp-mds
/mmds/src/lib.rs
UTF-8
7,590
2.65625
3
[]
no_license
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use serde_json::{Map, Value}; use static_init::dynamic; mod data_store; use data_store::{Error as MmdsError, Mmds}; #[dynamic] static mut MMDS: Mmds = Mmds::default(); /// Patch provided JSON document (gi...
true
48183a8a0650361e7cdb512c625323c097488fdd
Rust
mbrobbel/advent-of-code
/2019/day6/src/main.rs
UTF-8
2,301
3.4375
3
[ "Unlicense" ]
permissive
use std::{ collections::{HashMap, HashSet}, error::Error, io::Read, iter::FromIterator, }; fn count(graph: &HashMap<String, Vec<String>>, node: &str) -> u64 { graph.get(node).map_or(0, |values| { values.iter().fold(1, |mut acc, x| { acc += count(graph, x); acc ...
true
5c9d9173537ad4427da0cca521d1c2c1c40a4243
Rust
happenslol/rem
/src/main.rs
UTF-8
10,896
2.6875
3
[ "MIT" ]
permissive
use crate::{ config::{save_config, Config}, repo::Repo, }; use anyhow::{anyhow, bail, Context, Result}; use clap::{AppSettings, Clap}; use lazy_static::lazy_static; use regex::Regex; use std::env; use std::io::{self, Read}; use url::Url; mod config; mod git; mod github; mod gitlab; mod repo; lazy_static! { ...
true
e3cdd48fefff3e1db95438ade8d3bbf1a602f02e
Rust
adwhit/advent-of-code-2017
/src/bin/10_knot_hash.rs
UTF-8
3,530
3.109375
3
[]
no_license
#![feature(inclusive_range_syntax)] extern crate advent_of_code; #[macro_use] extern crate failure; use advent_of_code::Result; use std::fs; use std::io::prelude::*; fn get_data(path: &str) -> Result<Vec<u8>> { let mut f = fs::File::open(path)?; let mut s = String::new(); f.read_to_string(&mut s)?; ...
true
4d1582c6a87754a02bf2afed574aace39ab5b1c2
Rust
yannbolliger/rust-stainless-thesis-report
/thesis-report/src/code/lib.rs
UTF-8
4,875
2.84375
3
[]
no_license
extern crate stainless; use stainless::*; mod list; use list::*; /// Node IDs // PeerId was replaced by a simple u128 to make hashing easier. pub enum ErrorKind { NoWitnessLeft { context: Option<Box<ErrorKind>> }, } /// A generic container mapping `u128`s to some type `T`, /// which keeps track of the primary p...
true
fd60a4110208381e95aadad2375132e70ace8b80
Rust
dyna-dot/Selenium
/rust/src/manager.rs
UTF-8
4,076
2.734375
3
[ "Apache-2.0" ]
permissive
use std::error::Error; use std::path::PathBuf; use std::process::Command; use crate::downloads::download_driver_to_tmp_folder; use crate::files::{parse_version, uncompress}; use crate::metadata::{create_browser_metadata, get_browser_version_from_metadata, get_metadata, write_metadata}; pub trait BrowserManager { ...
true
047e30d4c7ee90f10711c4dc649d722fd72b9ceb
Rust
wisest30/AlgoStudy
/source/leetcode/2316/hyo.rs
UTF-8
971
2.765625
3
[]
no_license
impl Solution { pub fn dfs(cur: usize, visited: &mut Vec<bool>, e: &Vec<Vec<usize>>) -> usize { if visited[cur] { 0 } else { visited[cur] = true; let mut ret = 1usize; for &nxt in &e[cur] { ret += Solution::dfs(nxt, visited, &e); ...
true
d4dc51b1859becf510910b4041d959a6592ea78b
Rust
David-Kunz/proc-macro
/tests/basic.rs
UTF-8
367
3.15625
3
[]
no_license
use derive_entity::Entity; use entity::{Select,Sql}; #[derive(Entity)] pub struct Book { id: u64, title: String, pages: u64, author: String, } fn main() { let mut select = Book::select(); select.set_limit(200).set_unique().set_columns(vec!["id", "title"]); assert_eq!("select distinct id,ti...
true
695abb2e8315fb12aea5e65d01e5cceef2b659cb
Rust
alexliesenfeld/httpmock
/src/common/data.rs
UTF-8
14,065
2.6875
3
[ "LicenseRef-scancode-philippe-de-muyter", "MIT" ]
permissive
extern crate serde_regex; use std::cmp::Ordering; use std::collections::BTreeMap; use std::fmt; use std::fmt::Debug; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::Relaxed; use std::sync::{Arc, RwLock}; use std::time::Duration; use regex::Regex; use serde::{Deserialize, Serialize}; use serde_jso...
true
08b5394ae5924dd07cf07d8b891dbec1ebd3cbc5
Rust
gnames/gnparser-rs
/src/output/simple.rs
UTF-8
1,049
2.53125
3
[]
no_license
use crate::peg; use csv; use std::error::Error; pub fn header() -> String { "Id,Verbatim,CanonicalFull,CanonicalSimple,CanonicalStem,Authorship,Year,Quality".to_string() } pub fn row(sn: peg::SciName) -> Result<String, Box<dyn Error>> { let mut can_full = String::new(); let mut can_simple = String::new();...
true
a3e9054a8a6ccc65331fdbb3310d663a420d71c9
Rust
aticu/size_format
/src/lib.rs
UTF-8
14,090
3.875
4
[ "Apache-2.0", "MIT" ]
permissive
//! # size_format //! //! This crate provides formatting for sizes. //! //! The main goal is to provide easy formatters for data sizes. //! //! It provides both binary and SI unit prefixes per default, though more could be added. //! ``` //! use size_format::{SizeFormatterBinary, SizeFormatterSI}; //! //! assert_eq!( /...
true
4e00254ffe86f308eb6b494e97c34b2d27412dd0
Rust
FiloSanza/rust-raytracing
/src/objects/constant_medium.rs
UTF-8
2,129
2.796875
3
[]
no_license
use super::material::{isotropic::Isotropic, material::Material}; use super::hittable::{HitRecord, Hittable}; use super::bounding::BoundingBox; use super::{min_f64, max_f64}; use super::textures::Texture; use super::vec3::Vec3; use super::ray::Ray; use std::rc::Rc; use std::f64; use rand::Rng; pub struct ConstantMedi...
true
c7cf994796dadc8a129f7d91e617c68a277a01a7
Rust
kjetilkjeka/uavcan.rs
/dsdl_compiler/src/config.rs
UTF-8
1,362
3.625
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Configurable options relating to compilation use std::str::FromStr; /// Makes certain things in the compilation process configurable. `CompileConfig::default()` is generally safe to use. pub struct CompileConfig { /// Compile data type signatures for types `#[DataTypeSignature = "0x12345678"]` pub data_ty...
true
10f3cddacc706173c56c7533c2996039a105d899
Rust
hone/jarvis
/src/marvel_champions.rs
UTF-8
2,199
3.09375
3
[]
no_license
use crate::{CardSearch, DbCard}; use rayon::prelude::{IntoParallelIterator, ParallelIterator}; use serde::Deserialize; const IMAGE_HOST: &str = "https://marvelcdb.com"; const CARDS_API: &str = "https://marvelcdb.com/api/public/cards/"; #[derive(Deserialize)] pub struct Card { pub code: String, pub name: Strin...
true
530e1087c71b96f30282b371ecc6da8278261aa2
Rust
jduan/cosmos
/rust_sandbox/async_std_example/src/main.rs
UTF-8
2,994
3.4375
3
[ "MIT" ]
permissive
use async_std::task::{sleep, spawn, Context, Poll}; use pin_project_lite::pin_project; use std::future::Future; use std::pin::Pin; use std::time::Duration; #[async_std::main] async fn main() { // Here we spawn 3 async functions. This shows that all of them run in // the same main thread. You can adjust the num...
true
6e4e2ec78d67aebe58aa3a1a606762f0fcff75d6
Rust
FernandoToigo/tetris-rs
/src/time.rs
UTF-8
1,035
2.96875
3
[]
no_license
use std::time::Instant; pub struct StdClock { } pub struct StdInstant { instant: Instant } impl Clock<StdInstant> for StdClock { fn now(&self) -> StdInstant { StdInstant { instant: Instant::now() } } } impl ClockInstant for StdInstant { fn difference_millis(&self, other_...
true
ad8aab0a8219840e78c968893b608eaae23ac030
Rust
YoungForest/leetcode-rust
/src/problems/problem1180.rs
UTF-8
596
3.296875
3
[]
no_license
struct Solution {} impl Solution { pub fn count_letters(s: String) -> i32 { let mut ans = 0; if s.is_empty() { return 0; } let s = s.into_bytes(); let mut c = s[0]; let mut count = 1; ans = 1; for i in 1..s.len() { if c == s[i] ...
true
f6a0c8a5f90fe61034414d2e8c6f5f30efe74fb4
Rust
chryslovelace/advent-of-code-2018
/src/bin/day06/main.rs
UTF-8
2,669
3.375
3
[]
no_license
use itertools::iproduct; use lazy_static::lazy_static; use scan_fmt::scan_fmt; use std::{ cmp::Ordering, collections::{HashMap, HashSet}, }; lazy_static! { static ref COORDINATES: Vec<(i32, i32)> = include_str!("input.txt") .lines() .map(|line| { let (x, y) = scan_fmt!(line, "{d...
true
83ea65ddacee172e0aa75ae9c0529671729b7416
Rust
slionx/rocket-demo
/src/controller/frontend/index.rs
UTF-8
1,079
2.625
3
[ "MIT" ]
permissive
use crate::response::demo::Demo; use crate::request::api_user::ApiUser; use rocket_contrib::databases::diesel; use diesel::prelude::*; use crate::models::{ApiUserSecret, InsertableApiUserSecret}; use crate::schema::*; use std::error::Error; use crate::connection::*; use serde::Serialize; use rocket_contrib::json::Json;...
true
cb9db52bd59ac77893f94b1d1296877b44c25131
Rust
jfecher/ante
/src/types/effects.rs
UTF-8
8,009
2.78125
3
[ "MIT" ]
permissive
use crate::cache::{EffectInfoId, ModuleCache}; use crate::error::location::Location; use crate::types::typechecker::TypeBindings; use crate::types::Type; use crate::util::fmap; use super::typechecker::{self, OccursResult, UnificationBindings}; use super::{TypeBinding, TypeVariableId}; #[derive(Debug, Clone, Eq, Parti...
true
b5be14377598a3b5e91cc14dea55006ae1754a16
Rust
solana-labs/rust-bpf-sysroot
/src/std/src/sys/sgx/waitqueue/spin_mutex/tests.rs
UTF-8
469
2.8125
3
[ "Apache-2.0" ]
permissive
#![allow(deprecated)] use super::*; use crate::sync::Arc; use crate::thread; use crate::time::Duration; #[test] fn sleep() { let mutex = Arc::new(SpinMutex::<i32>::default()); let mutex2 = mutex.clone(); let guard = mutex.lock(); let t1 = thread::spawn(move || { *mutex2.lock() = 1; }); ...
true
eebc9596b745e9e2ba3a0220924aecea36b659e0
Rust
storiqaamericanteam/Autotests
/functional-tests/src/config.rs
UTF-8
1,964
2.71875
3
[]
no_license
use std::env; use config_crate::{Config as RawConfig, ConfigError, Environment, File}; #[derive(Debug, Deserialize, Clone)] pub struct Config { pub gateway_microservice: GatewayMicroservice, pub users_microservice: Microservice, pub stores_microservice: Microservice, pub saga_microservice: SagaMicrose...
true
19ef842f65baaddfb5f3948bba4c8995d69888d7
Rust
0xA537FD/binance-rs-async
/src/lib.rs
UTF-8
2,931
2.546875
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT", "Apache-2.0" ]
permissive
//! [![github]](https://github.com/Igosuki/binance-rs-async)&ensp;[![crates-io]](https://crates.io/Igosuki/binance-rs-async)&ensp;[![docs-rs]](https://docs.rs/binance-rs-async) //! //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github //! [crates-io]: https://img.shi...
true
30e0adbb9bb0667736f2993d4a734a012f911123
Rust
gh0stl1m/rust-basics
/4.VariableBindings/4.2.scopeAndShadowing.rs
UTF-8
1,562
3.6875
4
[]
no_license
/** * Variable bindings have a scope, and are constrained to live in a block. * A block is a collection of statements enclosed by braces {}. Also, variable shadowing is allowed. * * It's possible to declare variable bindings first, and initialize them later. However, this form is seldom used, as it may lead to the...
true
d1f482fa45e07b2c29af57f3f2bbc438e7e13855
Rust
magurotuna/leetcode-rust
/src/bin/1383.rs
UTF-8
1,945
3.375
3
[]
no_license
struct Solution; impl Solution { pub fn max_performance(n: i32, speed: Vec<i32>, efficiency: Vec<i32>, k: i32) -> i32 { use std::cmp::{max, Reverse}; use std::collections::BinaryHeap; let mut bh = BinaryHeap::new(); let MOD = 1_000_000_007; let mut se: Vec<(i64, i64)> = spee...
true
641f1d23d0c2fc0c78e029e5f80bd7e7f3c4cc0c
Rust
ipoemigmail/rust-study
/multi-ssh/src/main.rs
UTF-8
2,593
2.8125
3
[]
no_license
use std::{error::Error, string}; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::env; use futures::{FutureExt, stream::{self, StreamExt}}; use openssh::{KnownHosts, Session}; use serde::{Deserialize, Serialize}; #[derive(Debug)] enum MyError { OpenSshError(openssh::Error), JoinErr...
true
9be8fc8ea2155817c021319c9ce853d0cb3f3286
Rust
lexs/rust-os
/rost/drivers/vga.rs
UTF-8
2,889
2.859375
3
[]
no_license
use core::prelude::*; use core::intrinsics::volatile_store; use arch::io; bitflags!( #[packed] flags Color: u8 { static BRIGHT = 1 << 3, static BLACK = 0, static RED = 1 << 2, static GREEN = 1 << 1, static BLUE = 1 << 0, static CYAN = BLUE.bits | GREEN.bits, ...
true
5ee7ce4e5bae47fe5da72ee23ad9c265e8bb559e
Rust
servo/green-rs
/librustuv/tests/udp.rs
UTF-8
7,210
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
use std::io::net::ip::{SocketAddr, Ipv4Addr}; use std::io::test::{next_test_ip4, next_test_ip6}; use std::time::Duration; use green::task::spawn; use rustuv::{uvll, Udp}; test!(fn bind_error() { let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 }; match Udp::bind(addr) { Ok(..) => panic!(), ...
true
5689604732369d54af610ca37f17051fdb1575ba
Rust
cnsr/leetcode
/414/lc414.rs
UTF-8
319
2.609375
3
[]
no_license
impl Solution { pub fn third_max(mut nums: Vec<i32>) -> i32 { use std::collections::HashSet; let set: HashSet<_> = nums.drain(..).collect(); // dedup nums.extend(set.into_iter()); nums.sort(); nums.reverse(); return if nums.len() < 3 {nums[0]} else {nums[2]} } }
true
5b263af972eb100ae9fd7523eb82f66acb8abd59
Rust
AndreyMakuha/math_modeling
/helper_fn/src/lib.rs
UTF-8
10,300
2.625
3
[ "MIT" ]
permissive
use pyo3::prelude::*; use pyo3::types::PyDict; use std::f64; use std::fs::File; use std::io::{self, prelude::*}; use rand::Rng; use std::fmt::Write; // Теоретические частоты попадания случайной величины в интервалы fn laplass(mw: f64, sd: f64, x: f64) -> PyResult<f64> { let gil = Python::acquire_gil(); let p...
true
9bb872b7a2bb76c599ab5b6d6548c04c35057afa
Rust
stanleydesu/rust-raytracing
/src/bin/blue_spheres.rs
UTF-8
4,631
2.5625
3
[ "MIT" ]
permissive
use raytracing::{ rand_f64, rand_in_range, write_sampled_color, Camera, Color, Dieletric, Hittable, HittableList, Lambertian, Material, Metal, Point3, Ray, Sphere, Vec3, }; use std::rc::Rc; fn random_scene() -> HittableList { let mut world = HittableList::default(); let ground_material = Rc::new(Lamber...
true
f23aa0c5d67fbf3178e771be05c11b74189383fc
Rust
aeyoll/vernam-rs
/src/main.rs
UTF-8
1,372
2.84375
3
[ "MIT" ]
permissive
use std::process; #[macro_use] extern crate clap; use clap::App; use clap::ArgMatches; mod lib; #[macro_use] extern crate failure; use failure::Error; use lib::Vernam; fn build_vernam(submatches: &ArgMatches) -> Result<Vernam, Error> { let message = submatches.value_of("message").unwrap().to_string(); let ...
true
cd8dd84e0f2b03150c23636b7405b334c285cbc6
Rust
GaloisInc/mir-verifier
/lib/libstd/sys_common/mutex.rs
UTF-8
3,015
3.3125
3
[]
permissive
use crate::sys::crux::mutex as imp; /// An OS-based mutual exclusion lock. /// /// This is the thinnest cross-platform wrapper around OS mutexes. All usage of /// this mutex is unsafe and it is recommended to instead use the safe wrapper /// at the top level of the crate instead of this type. pub struct Mutex(imp::Mut...
true
c217f29b23841834d8da792d3e7c7bce49203e81
Rust
bazelbuild/rules_rust
/proto/prost/private/tests/types/types_test.rs
UTF-8
3,414
3.015625
3
[ "Apache-2.0" ]
permissive
use types_proto::Enum; use types_proto::{types, Types}; #[test] fn test_types() { Types { a_enum: Enum::C.into(), a_double: 2.0, a_float: 3.0, a_int32: 4, a_int64: 5, a_uint32: 6, a_uint64: 7, a_sint32: 8, a_sint64: 9, a_fixed32: 10, ...
true
83dcdbfb3c3b7aa8d7feefc4b1e905c3103d0de1
Rust
CrystalGamma/irc-zerocopy
/src/lib.rs
UTF-8
3,839
2.71875
3
[ "MIT" ]
permissive
pub mod parse; pub use parse::{IrcMessage, parse_irc_message}; pub mod reader; pub use reader::IrcReader; use std::convert::AsRef; trait FirstCharExt: AsRef<str> { fn first_char(&self) -> char {self.as_ref().chars().next().expect("tried to get the first code point of an empty string")} } impl<S: AsRef<str>> FirstCh...
true
3fa6dac1ae193953fd8a3d1e206f19bd159f4847
Rust
ethankhall/crom
/src/models/user_config.rs
UTF-8
4,006
2.96875
3
[ "BSD-3-Clause" ]
permissive
use serde::{Deserialize, Serialize}; use std::collections::HashMap; use crate::version::VersionMatcher; #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "kebab-case")] pub struct CromConfig { #[serde(flatten)] pub project: ProjectConfig, #[serde(default)] pub artifact: HashMap<String, Pr...
true
10b2dde5fb04d187bbdbb1323064a39b6a6b5719
Rust
s1na/ruster
/src/error.rs
UTF-8
479
3.03125
3
[ "MIT" ]
permissive
use std::error; use std::fmt; #[derive(Debug, Clone)] pub struct Error { msg: String, } impl Error { pub fn new(m: &str) -> Error { Error { msg: m.to_string() } } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.msg) } } ...
true
cc6df4678b15ccd118cd37a5f5df0031bc440262
Rust
birkenfeld/rust-ctrlc
/src/lib.rs
UTF-8
2,562
2.828125
3
[]
no_license
//! A simple easy to use wrapper around Ctrl-C signal. #![cfg_attr(feature="nightly", feature(static_condvar))] #![cfg_attr(feature="nightly", feature(static_mutex))] extern crate libc; #[cfg(feature="stable")] #[macro_use] extern crate lazy_static; #[cfg(feature="nightly")] mod features { use std::sync::{Static...
true
a4f69b4595456b7f71ebffcf1987d3aeeea2a64f
Rust
etorth/sniprun
/src/interpreters/Python3_original.rs
UTF-8
11,803
2.78125
3
[ "MIT" ]
permissive
#[derive(Clone)] #[allow(non_camel_case_types)] pub struct Python3_original { support_level: SupportLevel, data: DataHolder, code: String, imports: String, interpreter: String, main_file_path: String, plugin_root: String, cache_dir: String, venv: Option<String>, } impl Python3_origin...
true
0c286a6e617d55954218349f4917efd4f2c495fe
Rust
LeedsCodeDojo/Connect4
/rustExample/src/api.rs
UTF-8
7,305
2.6875
3
[]
no_license
#![allow(non_snake_case)] use rustc_serialize::{Decodable, Decoder}; use rustc_serialize::json; use hyper::{self, Client}; use std::io::Read; const SERVER_URL: &'static str = "http://yorkdojoconnect4.azurewebsites.net/"; static TEAM_NAME: &'static str = "rustPlayer"; static TEAM_PASSWORD: &'static str = "asiduhfasjfh...
true
425a99a42b58abc8338002eda949bbc08f7599ec
Rust
mcountryman/scraptor
/src/driver/dxgi/frame.rs
UTF-8
6,446
2.875
3
[]
no_license
use crate::{ bindings::Windows::Win32::{ Foundation::RECT, Graphics::Dxgi::{IDXGIOutputDuplication, DXGI_OUTDUPL_MOVE_RECT}, }, driver::dx11::frame::Dx11FrameData, DirtyRect, Frame, FrameFormat, MovedPoint, MovedRect, }; use std::{borrow::Cow, cmp::min}; #[derive(Debug, Clone)] pub struct DxgiFrame<'a>...
true
d98082c69c63d37b5d127b1c1a47027db5c8d3c6
Rust
Anode194/rss_gen
/src/input.rs
UTF-8
4,586
2.796875
3
[]
no_license
extern crate nom; use crate::config::Post; use crate::config::ConfigData; use crate::config::read_config; use std::vec::Vec; use nom::{ bytes::complete::is_not, bytes::complete::tag, bytes::complete::take_until, // branch::Alt, needed for parsing multiple h tags for finding the heading. ...
true
ea55e54fded8a63210696f0b36e05f56f12f5087
Rust
Botcoins/watchdog
/src/processes.rs
UTF-8
2,513
2.8125
3
[ "MIT" ]
permissive
use config::WatchdogCfg; use std::fs; use std::process::{Child, Command}; use std::sync::mpsc::Receiver; use std::thread; use std::time::Duration; pub struct WatchedChild { cfg: WatchdogCfg, exe_path: String, child: Child, } impl WatchedChild { pub fn spawn(cfg: WatchdogCfg, rebuild: bool) -> Result<WatchedChild,...
true
6fb85b748f7646d9fbf95ddba28942bcfc34e402
Rust
laanwj/k210-pac
/src/sysctl/reset_status.rs
UTF-8
9,158
2.65625
3
[ "ISC" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::RESET_STATUS { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, ...
true
584c6f819c3b6a31cb93f4675a172211607eabf8
Rust
Jackson93150/RetroRunner-
/src/tir.rs
UTF-8
1,109
3.46875
3
[]
no_license
use ggez::nalgebra::Point2; use ggez::nalgebra::Vector2; use ggez::{Context, GameResult}; pub struct Tir { pub position: Vector2<f32>, pub state: bool, //point de vie pub movement_right: f32, } impl Tir { pub fn new(_context: &mut Context) -> GameResult<Self> { let position = Vector2::new(250...
true
b3130fe87e9500aeee0a2e63ae0d888c5695aa32
Rust
cloudera/hue
/tools/ace-editor/demo/kitchen-sink/docs/rust.rs
UTF-8
495
3.1875
3
[ "CC-BY-3.0", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-unknown-license-reference", "ZPL-2.0", "Unlicense", "LGPL-3.0-only", "CC0-1.0", "LicenseRef-scancode-other-permissive", "CNRI-Python", "LicenseRef-scancode-warranty-disclaimer", "GPL-2.0-or-later", "Python-2.0", "GPL-3.0...
permissive
use core::rand::RngUtil; fn main() { for ["Alice", "Bob", "Carol"].each |&name| { do spawn { let v = rand::Rng().shuffle([1, 2, 3]); for v.each |&num| { print(fmt!("%s says: '%d'\n", name, num + 1)) } } } } fn map<T, U>(vector: &[T], function...
true
1a8dfbdc2fef1f25f96772b51af50ed91ebeb0e3
Rust
stackcats/leetcode
/algorithms/easy/search_insert_position.rs
UTF-8
522
3.203125
3
[ "MIT" ]
permissive
// https://leetcode.com/problems/search-insert-position/ impl Solution { pub fn search_insert(nums: Vec<i32>, target: i32) -> i32 { let mut i = 0; let mut j = nums.len() as i32 - 1; while i <= j { let mid = i + (j - i) / 2; if nums[mid as usize] == target { ...
true
3b960ea8237af40e650c42a9deea92c4bbf58163
Rust
serenity-rs/serenity
/src/framework/standard/structures/check.rs
UTF-8
2,732
3.3125
3
[ "ISC" ]
permissive
use std::error::Error; use std::fmt; use futures::future::BoxFuture; use crate::client::Context; use crate::framework::standard::{Args, CommandOptions}; use crate::model::channel::Message; /// This type describes why a check has failed. /// /// **Note**: /// The bot-developer is supposed to process this `enum` as th...
true
ae15b5cf95c6890c6bf1defcc985407b95b24bc2
Rust
SpectralSequences/sseq
/ext/crates/fp/src/matrix/subspace.rs
UTF-8
6,447
3.265625
3
[ "Apache-2.0", "MIT" ]
permissive
use super::Matrix; use crate::prime::ValidPrime; use crate::vector::{FpVector, Slice, SliceMut}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use std::io::{Read, Write}; /// A subspace of a vector space. /// /// In general, a method is defined on the [`Subspace`] if it is a meaningful property of the /...
true
a19ea48eb23b3fb569c16d468f021955875978e6
Rust
typst/typst
/crates/typst-library/src/text/mod.rs
UTF-8
27,757
3.328125
3
[ "Apache-2.0", "Bitstream-Vera", "CC-BY-4.0", "OFL-1.1", "LicenseRef-scancode-gust-font-1.0", "BSD-3-Clause", "LicenseRef-scancode-ubuntu-font-1.0", "0BSD", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-public-domain", "MIT", "LicenseRef-scancode-public-domain-disclaimer" ]
permissive
//! Text handling. mod deco; mod misc; mod quotes; mod raw; mod shaping; mod shift; pub use self::deco::*; pub use self::misc::*; pub use self::quotes::*; pub use self::raw::*; pub use self::shaping::*; pub use self::shift::*; use rustybuzz::Tag; use ttf_parser::Rect; use typst::font::{Font, FontStretch, FontStyle, ...
true
4bc4ec048d6a09043277f3e597ef950f3b018ed6
Rust
romac/cask
/src/cask.rs
UTF-8
22,421
2.65625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::hash_map::{Entry as HashMapEntry, Keys}; use std::collections::{BTreeSet, HashMap}; use std::default::Default; use std::path::PathBuf; use std::result::Result::Ok; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex, RwLock}; use std::thread; use std::time::Duration; use std:...
true
d56adef7240835779c7e8c2d985e49ea902d4bb4
Rust
konamilk/atcoder-abc177
/src/bin/a.rs
UTF-8
257
2.546875
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::{Chars, Bytes}; fn main() { input!{ d: i32, t: i32, s: i32 } if d <= t * s { println!("Yes"); } else { println!("No"); } }
true
c438e0cf805baab01a26b481c59f0caf2ccf585a
Rust
Visse/Bluntforge
/server/src/main.rs
UTF-8
1,028
2.75
3
[]
no_license
use std::net::SocketAddr; use futures_util::StreamExt; use log::*; use warp::{Filter, ws::WebSocket}; async fn accept_connection(socket: WebSocket) { match handle_connection(socket).await { Ok(()) => (), Err(e) => { error!("Error handling stream: {:?}", e); } } } async fn...
true
aeb80f32b91dc576dc66f77fb7ca73f16c126ca7
Rust
lloydmeta/frunk
/benches/monoid.rs
UTF-8
774
2.546875
3
[ "MIT" ]
permissive
#![feature(test)] extern crate frunk; extern crate test; use frunk::monoid::*; use test::Bencher; #[bench] fn combine_all_i32(b: &mut Bencher) { let v = vec![ Some(1), Some(2), Some(3), Some(4), Some(5), Some(6), Some(7), Some(8), Some(9), ...
true
eae3d4a43c4054f44fa0a69f20aee385e6baac1b
Rust
arafat877/git-git
/src/commands/merge.rs
UTF-8
2,926
2.875
3
[]
no_license
use crate::command_chain::*; use crate::commands::*; use crate::git::{branch_exists, current_branch_with_confirm, ConfirmDefault, Git}; use clap::ArgMatches; use std::string::ToString; pub fn run_merge(args: &ArgMatches) { MergeArgs::from_args(&args) .unwrap() .parse_args_and_run_command(&args, mer...
true
ec7656a4442355ffbbbd95c660167de555cd0eae
Rust
yati-sagade/autodiff-rust
/src/main.rs
UTF-8
2,890
2.96875
3
[ "MIT" ]
permissive
extern crate autodiff; extern crate num; extern crate gnuplot; use autodiff::AutoDiff; use std::io::{self,Write}; use num::Float; use gnuplot::{Figure, Caption, Color, LegendOption, Coordinate}; use std::f64::consts::PI; // A function `fn plot_fn_with_derivative<T, F>(func: F...) where F: Fn(T) -> T` // does not work...
true
98455c8f4e3c8031ea341be2e7df0ec6ce1a04f7
Rust
RussellPaine/AdventCode2020
/day_six/main.rs
UTF-8
1,059
3.390625
3
[]
no_license
use std::fs; fn main() { let data = fs::read_to_string("input.in").expect("Unable to read file"); let lines: Vec<&str> = data.split("\n\n").collect(); let mut c = 0; for line in lines { // let mut y: Vec<char> = Vec::new(); // for elem in line.chars() { // if elem == '\n' ...
true
fb616f1cf7454a11782165f149bd7c576854bcfe
Rust
imuxin/kubectl-watch
/difftastic-lib/src/diff/myers_diff.rs
UTF-8
787
3.125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A fast diff for linear content, using Myer's diff algorithm. #[derive(Debug)] pub enum DiffResult<T> { Left(T), Both(T, T), Right(T), } pub fn slice<'a, T: PartialEq + Clone>(lhs: &'a [T], rhs: &'a [T]) -> Vec<DiffResult<&'a T>> { wu_diff::diff(lhs, rhs) .into_iter() .map(|result| ...
true
82952b774e4cbe67fed1946b915c2654ac746a6f
Rust
domain-independent-dp/didp-rs
/dypdl-heuristic-search/src/search_algorithm/data_structure/search_node/f_node.rs
UTF-8
49,121
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
use super::super::hashable_state::HashableSignatureVariables; use super::super::state_registry::{StateInRegistry, StateInformation, StateRegistry}; use super::super::transition_chain::{GetTransitions, RcChain, TransitionChain}; use super::super::util::exceed_bound; use super::BfsNode; use dypdl::variable_type::Numeric;...
true
fbe5dd7f2bba31ac245446a71ac35b0ed2532889
Rust
elipsitz/advent-of-code-2019
/day15/src/main.rs
UTF-8
11,199
3.140625
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use crate::MachineStatus::{BadOpcode, Finished, Blocked}; use std::collections::{HashMap, HashSet}; fn read_lines(filename: &str) -> impl Iterator<Item=String> { let file = File::open(filename).unwrap(); let reader = BufReader::new(file); reader.lines(...
true
7b0917f6f66dfadd6efaa43d189d5a0666715fc5
Rust
0xpr03/LineBuffer
/tests/perf_simple.rs
UTF-8
1,335
3.09375
3
[ "MIT" ]
permissive
use linebuffer::{typenum, LineBuffer}; use std::convert::TryInto; use std::time::*; #[test] #[ignore] fn perf_simple() { const AMOUNT: usize = 8192; let mut buffer: LineBuffer<(), typenum::U2048> = LineBuffer::new(AMOUNT); let start = Instant::now(); let max: u32 = 1_000_000_000; for i in 0..max { ...
true
9d629bebb9fcf5652b27392a9e178250b3a31688
Rust
gngeorgiev/semver_rs
/src/range.rs
UTF-8
15,884
3.21875
3
[ "MIT" ]
permissive
use crate::builder::{Builder, Options, Parseable}; use crate::comparator::{Comparator, ComparatorPair}; use crate::error::Error; use crate::expressions::{ COMPARATOR_LOOSE, COMP_REPLACE_CARETS, RANGE_HYPHEN, RANGE_HYPHEN_LOOSE, RANGE_OR, RANGE_TRIM_CARET, RANGE_TRIM_OPERATORS, RANGE_TRIM_TILDE, SPLIT_SPACES, };...
true
074555a9bd6413971eb8f9e8c5232e60545afa05
Rust
MartinBG/MiniGit
/src/dir_structs.rs
UTF-8
4,085
2.53125
3
[]
no_license
extern crate walkdir; use self::walkdir::WalkDir; use std::path::PathBuf; use std::ops::Deref; use ::dir_ops::*; use std::fs::{create_dir, remove_file}; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct DirItem { pub path: String, pub hash: String } impl DirItem { pub fn new() -> Self { DirI...
true
b01b8316c14d673f79edbe397b5be1ddce6ea7f5
Rust
rust-lang/rust
/tests/ui/borrowck/issue-111554.rs
UTF-8
641
3.484375
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
struct Foo {} impl Foo { pub fn foo(&mut self) { || bar(&mut self); //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable } pub fn baz(&self) { || bar(&mut self); //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable //~...
true
8527b47078cf057d75b08cb3c3ac19d40fcaa87e
Rust
doronz2/curv
/src/cryptographic_primitives/pairing/pairing_bls12_381.rs
UTF-8
3,854
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pub use super::traits::Pairing; use crate::elliptic::curves::bls12_381::g1; use crate::elliptic::curves::bls12_381::g2; use bls12_381::Gt; use bls12_381::pairing; use bls12_381::G2Prepared; use bls12_381::multi_miller_loop; pub use crate::elliptic::curves::traits::*; type FE1 = g1::FE; type GE1 = g1::GE; type PK1 = g...
true
1fed6f990258c51721b5487699352c827ff46695
Rust
sathishvinayk/rust_360
/concurrency/data_sharing_bt_threads.rs
UTF-8
339
3.453125
3
[]
no_license
use std::sync::Arc; fn loop_value(a: Arc<Vec<usize>>) { for value in 0..4 { let y = a.clone(); std::thread::spawn(move || { println!("looping thru each value {}", y[value]); }).join().expect("Error while spawning!"); } } fn main() { let x = Arc::new(vec![1,2,3,4,5]); ...
true
26b96cabf33742866ae8cb8fbffb55c2e11a0891
Rust
algon-320/denwa
/src/main.rs
UTF-8
16,271
2.625
3
[ "MIT" ]
permissive
mod pulse_ext; mod traffic_meter; use std::io::prelude::*; use std::io::{stdin, stdout}; use std::net::{Ipv4Addr, SocketAddr, ToSocketAddrs, UdpSocket}; use std::sync::{Arc, Mutex}; use std::thread::{sleep, spawn}; use std::time::{Duration, Instant}; use log::{debug, error, info}; use p2p_handshake::{ client::get...
true
ba25d44bcdd0cef9d4c75d0595ea8056739dfdbc
Rust
Ryan-Gribben/github-rs
/tests/gitignore.rs
UTF-8
1,427
2.703125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
extern crate github_rs as gh; extern crate serde_json; use gh::StatusCode; use gh::client::{Executor, Github}; use serde_json::Value; use std::io::BufReader; use std::io::prelude::*; use std::fs::File; fn auth_token() -> Result<String, std::io::Error> { let file = File::open("tests/auth_token")?; let mut reade...
true
43e8f3034190217b2aa67b1878414b9d69806aff
Rust
jgilchrist/advent-of-code
/rust/src/y2015/src/d04.rs
UTF-8
1,244
2.90625
3
[]
no_license
use prelude::*; pub struct Day04; fn all_hashes(input: &str) -> impl Iterator<Item = String> + '_ { let natural_numbers = iterate(0, |&i| i + 1); let natural_numbers_as_strings = natural_numbers.map(|i| i.to_string()); let infinite_challenge_input = std::iter::repeat(input); let inputs_with_numbers ...
true
0521c3d7b912c58ea75476f7186a02e628610459
Rust
astro/rust-lpc43xx
/src/sct/res/mod.rs
UTF-8
66,903
2.828125
3
[ "Apache-2.0" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::RES { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W...
true
71daad4043129cd3028a174064dd111667bb76a1
Rust
TAKEDA-Takashi/rust-project-euler
/project-euler/src/bin/problem-124.rs
UTF-8
436
2.71875
3
[]
no_license
//! http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%20124 //! Ordered radicals use euler_lib::Prime; use itertools::Itertools; fn main() { let ubound = 100_000; let prime = Prime::<usize>::new(); println!( "{:?}", (1..=ubound) .map(|n| (prime.factorizatio...
true
4a72ea9afb840d10bb79f8fca3c151cd345b9732
Rust
imoegirl/rust-by-example
/src/p041_generic_trait.rs
UTF-8
309
2.890625
3
[]
no_license
struct Empty; struct Null; trait DoubleDrop<T> { fn double_drop(self, _: T); } impl<T, U> DoubleDrop<T> for U { fn double_drop(self, _: T) {} } pub fn run() { println!("p041_generic_trait >>>>>>>>"); let empty = Empty; let null = Null; empty.double_drop(null); println!("\n"); }
true
5564bb4877c9b63fe1bf632b8f6035f5c7d75fe8
Rust
Dynisious/UniHack
/src/neural_net/mod.rs
UTF-8
6,096
2.8125
3
[]
no_license
use std::hash::{Hash, Hasher}; use std::collections::HashMap; mod neuron; use self::neuron::*; pub const LAYER_SIZE: usize = 20; pub const NEURAL_OUTPUT: usize = 3; #[derive(Clone, Serialize, Deserialize)] pub struct NeuralNet { layers: Vec<HashMap<usize, Neuron>>, } impl NeuralNet { pub fn new(layers: Ve...
true
7cb9d1eb3dd827ad4aeb3daad341adc9709a989c
Rust
flyer5200/reflow
/src/conf/prefix_match/util.rs
UTF-8
3,466
2.796875
3
[]
no_license
use bytes::Bytes; use std::collections::HashMap; use std::fs::{self, DirEntry}; use std::io; use std::path; pub fn find_domain_map_files(config: &path::Path) -> io::Result<HashMap<Bytes, Vec<DirEntry>>> { let p = config.join("namezone"); let mut m = if p.exists() { find_map_files(&p)? } else { ...
true
a71a9a29256d95f46eaca6f660a5a100600ff630
Rust
pbzweihander/async-h1
/src/chunked/encoder.rs
UTF-8
3,913
3.140625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use std::pin::Pin; use async_std::io; use async_std::io::prelude::*; use async_std::task::{Context, Poll}; use futures_core::ready; /// An encoder for chunked encoding. #[derive(Debug)] pub(crate) struct ChunkedEncoder<R> { reader: R, done: bool, } impl<R: Read + Unpin> ChunkedEncoder<R> { /// Create a n...
true
79ec22c60d64fb9d4c9a12932a39377b0a67e7ed
Rust
GuillaumeGomez/sysinfo
/src/windows/sid.rs
UTF-8
5,343
2.875
3
[ "MIT" ]
permissive
// Take a look at the license at the top of the repository in the LICENSE file. use std::{fmt::Display, str::FromStr}; use winapi::{ shared::{ sddl::{ConvertSidToStringSidW, ConvertStringSidToSidW}, winerror::ERROR_INSUFFICIENT_BUFFER, }, um::{ errhandlingapi::GetLastErro...
true
a1c9052151383854142020a2006fb34da4342e82
Rust
bazelbuild/rules_rust
/crate_universe/src/splicing.rs
UTF-8
22,157
2.53125
3
[ "Apache-2.0" ]
permissive
//! This module is responsible for finding a Cargo workspace pub(crate) mod cargo_config; mod crate_index_lookup; mod splicer; use std::collections::{BTreeMap, BTreeSet}; use std::convert::TryFrom; use std::fs; use std::path::{Path, PathBuf}; use std::str::FromStr; use anyhow::{anyhow, bail, Context, Result}; use ca...
true
d73e16f80c2e6f21bce07f94cf7cb887e8dd3a07
Rust
n1tram1/lr35902-disass
/src/analyzer/disassembler.rs
UTF-8
493
2.78125
3
[]
no_license
use super::error::AnalyzerError; use super::instruction::Instruction; pub struct Disassembler; impl Disassembler { pub fn disassemble(bytes: &Vec<u8>) -> Result<Vec<Instruction>, AnalyzerError> { let mut instructions: Vec<Instruction> = Vec::new(); let mut i = 0; while i < bytes.len() { ...
true
bdcbe8b6d795d4f566407e5893eb94d0f6bb0600
Rust
jaems33/intro-to-rust
/chapter_6/option_enum/src/main.rs
UTF-8
737
3.796875
4
[]
no_license
/* Option Enum encodes the idea of a value being present or absent. enum is Option<T> This is similar to the library implementation enum QuasiOption<T> { Some(T), None, } */ fn divide(num: i32, den: i32) -> Option<i32> { if den == 0 { return Option::None } Option::Some(num / den) } fn mai...
true
7f51cf2d59483a70c77dce048b7deac1c5c4ea73
Rust
brl/citadel-tools
/libcitadel/src/log.rs
UTF-8
3,405
2.921875
3
[]
no_license
use std::sync::Mutex; use std::io::{self,Write}; use crate::Result; lazy_static! { static ref LOGGER: Mutex<Logger> = Mutex::new(Logger::new()); } #[macro_export] macro_rules! debug { ($e:expr) => { $crate::Logger::log($crate::LogLevel::Debug, String::from($e)) }; ($fmt:expr, $($arg:tt)+) => { $crate::L...
true
0885529b73a3c7145990d44af738be2f63458add
Rust
PeterW-LWL/mail
/internals/src/bind/quoted_string.rs
UTF-8
3,100
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use quoted_string::spec::{ GeneralQSSpec, PartialCodePoint, WithoutQuotingValidator }; use media_type_impl_utils::quoted_string; use ::MailType; /// A Quoted String specification in context of Mail ([rfc5322](https://tools.ietf.org/html/rfc5322#section-2.2.3)) /// /// This implementation of MailQsSpec _do...
true
655c6930fcc4de83b456ec8fd82c4f0d041bf11b
Rust
ndtho8205/rust-simple-apps
/snake_game/src/game.rs
UTF-8
4,519
2.8125
3
[]
no_license
use piston_window::{clear, rectangle, Context, G2d, Key}; use rand::{thread_rng, Rng}; use crate::snake::*; const BACKGROUND_COLOR: [f32; 4] = [0.0, 0.0, 0.0, 1.0]; const GAME_OVER_BACKGROUND_COLOR: [f32; 4] = [1.0, 0.0, 0.0, 1.0]; const BORDER_COLOR: [f32; 4] = [1.0, 1.0, 1.0, 1.0]; const APPLE_COLOR: [f32; 4] = [1....
true
d193a3f7944118cadf986557dd75b4b1b0fe1c78
Rust
rust-lang/rust
/src/tools/clippy/tests/ui/significant_drop_tightening.rs
UTF-8
3,466
3.21875
3
[ "Apache-2.0", "MIT", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "LicenseRef-scancode-other-permissive" ]
permissive
#![warn(clippy::significant_drop_tightening)] use std::sync::Mutex; pub fn complex_return_triggers_the_lint() -> i32 { fn foo() -> i32 { 1 } let mutex = Mutex::new(1); let lock = mutex.lock().unwrap(); let _ = *lock; let _ = *lock; foo() } pub fn issue_10413() { let mutex = Mu...
true
46c852fcb19f2b5439d9855178efbc08bad03706
Rust
1kasu/gpeli
/src/fysiikka.rs
UTF-8
11,475
2.8125
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use std::time::Duration; use super::maailma::kappale::{Kappale, Muoto, Tagi}; use super::maailma::vektori::Vektori; use crate::maailma::Lisaosa; type RcKappale = Rc<RefCell<Kappale>>; /// Kohde, jolle voidaan laskea fysiikkaan liittyviä laskuja. pub trait Fysiikall...
true
9d17e92a036be8b6884a18da22fcb2424fd7d9fe
Rust
greyarch/dot-http
/src/controller/tests.rs
UTF-8
5,052
2.8125
3
[ "Apache-2.0" ]
permissive
use crate::controller::Controller; use http_test_server::{Request, TestServer}; use std::io::Write; use std::sync::mpsc::Receiver; use tempfile::NamedTempFile; #[test] fn test() { let server = TestServer::new().unwrap(); let _resource = server.create_resource("/defaults"); let _requests = server.requests()...
true
ddb2eba727d1e2c3a249151d8d42df63d1cd08e9
Rust
lights0123/sip-codec
/src/parser/header.rs
UTF-8
1,298
2.78125
3
[]
no_license
use http::header::{HeaderName, HeaderValue}; use nom::is_space; use super::is_newline; fn is_colon(ch: u8) -> bool { ch == b':' } fn is_colon_or_space(ch: u8) -> bool { is_colon(ch) || is_space(ch) } named!(pub header<&[u8], (HeaderName, HeaderValue)>, do_parse!( name: map_res!(take_till1!(is_colon_or_space), H...
true
a3a9d90cc736739f58e87a2c7a230b84386dc100
Rust
edjacob25/ComputationalFundaments
/FirstPart/Homework5/benches/benchmarks.rs
UTF-8
2,218
2.609375
3
[ "MIT" ]
permissive
use criterion::{criterion_group, criterion_main, Criterion}; use homework_5::{heapsort, mergesort, quicksort, read_file}; fn benchmark(c: &mut Criterion) { let mut random: [Vec<u32>; 5] = Default::default(); let mut sorted: [Vec<u32>; 5] = Default::default(); let mut reverse: [Vec<u32>; 5] = Default::defau...
true
29ec29877fb75af2fbef51b90b298e1cb461290b
Rust
redwarp/Advent-of-Code-2019
/src/bin/day03.rs
UTF-8
7,161
3.203125
3
[]
no_license
/// Probably the ugliest piece of code I ever wrote. Let's pretend it never existed. use adventofcode::files; #[derive(Debug)] struct Segment { a: (i32, i32), b: (i32, i32), direction: char, } impl Segment { fn does_intersect(&self, other_segment: &Segment) -> bool { if (self.is_vertical() && ...
true
9cd57cc5fd55df3ad00d165dd34528ddf44ad7a6
Rust
wangzhf/rs-learn
/base/src/test_pattern.rs
UTF-8
2,791
4.21875
4
[]
no_license
pub fn test_pattern() { let x = 1; let c = 'c'; match c { // 此时x会被覆盖成c x => println!("x: {}, c: {}", x, c), } // 此时x会被还原为1 println!("x: {}", x); } // 测试解构struct struct Point { x: i64, y: i64, } pub fn test_pattern2() { let point = Point { x: 0, y: 0 }; match...
true
9f149371d4388b37ab299a73e015af9b25cfc989
Rust
itang/tests
/test-rusts/test-iron-open-browser/src/main.rs
UTF-8
1,186
3.0625
3
[]
no_license
extern crate iron; use iron::prelude::*; use std::process::Command; use std::time; use std::net::TcpListener; use std::thread; const PORT: u16 = 3000u16; fn hello_world(_: &mut Request) -> IronResult<Response> { Ok(Response::with((iron::status::Ok, "Hello world!"))) } fn tcp_port_available(port: u16) -> bool { ...
true
282d99b25715ac8cbba27cf7cf02fd2b9f1a3e20
Rust
energister/rusty_engine
/examples/level_creator.rs
UTF-8
7,709
3.40625
3
[ "LicenseRef-scancode-unknown-license-reference", "CC0-1.0", "MIT", "Apache-2.0" ]
permissive
use rusty_engine::prelude::*; const MAX_LAYER: f32 = 900.0; fn main() { println!( " This is an example of how you could write a level creater. This example lets you place actors, and generate the code you can copy-and-paste into a main.rs file to recreate that level. Controls R - Reset actor to default ...
true
835bd6c071e40cd1f38c245ee47f628a5eeaf97c
Rust
risooonho/kludgine
/src/style/font_size.rs
UTF-8
880
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ math::{Length, Raw, Scale, Scaled}, style::{Style, StyleComponent}, }; #[derive(Debug, Copy, Clone)] pub struct FontSize<Unit: Default + Copy>(pub Length<f32, Unit>); impl Default for FontSize<Scaled> { fn default() -> Self { Self::new(14.) } } impl<Unit: Default + Copy> FontSize...
true
e341178b946ffa01434b3035de95bb297d9559a2
Rust
ngwemo/hackerrank-challenges-rust
/src/challenges/thirty_days_of_code/day_20.rs
UTF-8
952
3.296875
3
[]
no_license
// 20. Sorting // https://www.hackerrank.com/challenges/30-sorting #![allow(unused_variables)] use crate::functions; pub fn main() { let _ = functions::read_line().trim(); let input: String = String::from(functions::read_line().trim()); let mut row = input .split(' ') .into_iter() ...
true
3b6b81e0c6792a7c15180b1469075c47519096b3
Rust
lemmi/AOC-2017
/star05/src/main.rs
UTF-8
1,561
3.734375
4
[ "Unlicense" ]
permissive
use std::io; use std::io::BufRead; use std::ops; // (y, x) ----> // | // | // | // v #[derive(Debug)] struct Point { y: i32, x: i32, } impl ops::Add for Point { type Output = Point; fn add(self, other: Point) -> Point { Point { y: self.y+other.y, x: self.x+other.x,...
true
6db8ce9855d4a59d1ce9554d0da57584cd9f9f24
Rust
fahrenkrug/rust_learn_book_chapter_16
/src/message_passing_examples.rs
UTF-8
1,740
3.28125
3
[]
no_license
use std::sync::mpsc; use std::thread; use std::time::Duration; pub fn run() { first_channel_example(); multiple_values_example(); multiple_producer_example(); } fn first_channel_example() { let (tx, rx) = mpsc::channel(); thread::spawn(move || { let val = String::from("Hello!"); tx...
true