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
bf18f2d7975b06b713e4ace36c468e6eb653e02b
Rust
pjzhong/wasm_game
/src/swoop_11_wingtip_trails_and_optimizations/src/camera.rs
UTF-8
1,655
2.96875
3
[]
no_license
use super::transform::{length, Transform2d, Vec2}; const PREDICT_FACTOR: f32 = 0.6; const ZOOM_FACTOR: f32 = 0.825; const SMOOTHING: f32 = 0.4; /// What the zoom is set to after calling "reset" const RESET_ZOOM: f32 = 10.0; pub struct Camera { position: Vec2, zoom: f32, pub target_posiion: Vec2, pub t...
true
9b95f0a8916681e9edc06886c1b0bcc71946df38
Rust
project-ela/rota
/src/frontend/parser.rs
UTF-8
8,858
2.796875
3
[ "MIT" ]
permissive
pub mod node; use x86asm::instruction::mnemonic; use crate::{ common::error::{Error, ErrorKind}, frontend::{ lexer::token::{Keyword, Symbol, Token, TokenKind}, parser::node::{ DispNode, InstructionNode, MemoryNode, OperandNode, Program, PseudoOp, PseudoOpArg, }, }, }; ...
true
7e348470dfae780a4f059d1991b50566eb6ac9d5
Rust
p-alik/wundergraph
/wundergraph/tests/query_nested.rs
UTF-8
3,512
2.6875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::helper::*; use wundergraph_example::MyContext; #[test] fn query_filter_eq_not_nullable_child() { let (schema, pool) = get_example_schema(); let ctx = MyContext::new(pool.get().unwrap()); let res = execute_query( &schema, &ctx, r#" { Heros(filter: {species: {name: {eq...
true
1f5e2925abdecffa52016912b846a77ba4b502ad
Rust
konamilk/atcoder-abc151
/src/bin/c.rs
UTF-8
874
2.6875
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::source::auto::AutoSource; #[allow(unused_imports)] use proconio::marker::{Chars, Bytes}; #[allow(unused_imports)] use num::integer::{sqrt, gcd, lcm}; #[allow(unused_imports)] use std::cmp::{max, min, Reverse}; fn main() { // let source = AutoSource::from(...
true
2657f0339ed62a4168e9731a73ae3b1fd2d6945b
Rust
ToruNiina/rust-practice-project-euler
/problem013/src/main.rs
UTF-8
514
2.984375
3
[]
no_license
extern crate num; use num::bigint::BigUint; use num::traits::Zero; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; fn main() { let file = File::open("problem013.dat").unwrap(); let buf = BufReader::new(&file); let nums = buf.lines() .map(|l| BigUint::parse_bytes(l.unwrap().as...
true
e2174c9f6d2a0c7c530a4572b848da9472703c2d
Rust
FGRibreau/lapin
/src/connection.rs
UTF-8
15,858
2.546875
3
[ "MIT" ]
permissive
use crate::{ channel::Channel, channels::Channels, close_on_drop, configuration::Configuration, connection_properties::ConnectionProperties, connection_status::{ConnectionState, ConnectionStatus, ConnectionStep}, executor::{DefaultExecutor, Executor}, frames::Frames, internal_rpc::{I...
true
1465d35631024dd451b3fc6039504b8fe3648886
Rust
kuehnelth/rust_portforwarder
/src/main.rs
UTF-8
1,366
2.828125
3
[ "WTFPL" ]
permissive
use std::*; use getopts::Options; use simple_logging; use log::LevelFilter; mod portforwarder; use portforwarder::{forward, get_ipv4_socket_addr}; fn print_usage(program: &str, opts: Options) { let brief = format!("Usage: {} [options]", program); print!("{}", opts.usage(&brief)); } fn main() -> Result<(),...
true
db9531fa1a882355c4c06643856b668927500303
Rust
ax-rwnd/d7018e-lpc1347-support
/macros/src/lib.rs
UTF-8
5,255
2.828125
3
[ "MIT" ]
permissive
//! Procedural macros of the `cortex-m-rtfm` crate #![deny(warnings)] #![feature(proc_macro)] #![recursion_limit = "128"] #[macro_use] extern crate error_chain; extern crate proc_macro; #[macro_use] extern crate quote; extern crate rtfm_syntax as syntax; extern crate syn; use proc_macro::TokenStream; use syntax::App;...
true
6b0e1fbbc6e2a443861672168693ad54706c6793
Rust
nerosnm/punch-clock
/src/event.rs
UTF-8
574
3.109375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; /// Represents a (possibly ongoing) period of time tracking, with its associated metadata. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub struct Event { /// The start of a time-tracking period. pub start: Dat...
true
32489f44e628dd34db2e8e6a866c4646c809161c
Rust
seanlth/Fluid-Solver
/src/fluid_solver.rs
UTF-8
8,228
2.671875
3
[]
no_license
extern crate lodepng; use std::io::prelude::*; use std::fs::File; use field::Field; use linear_solvers; use integrators; use advection; use interpolation; pub struct FluidSolver { pub velocity_x: Field, pub velocity_y: Field, pub density: Field, pub pressure: Field, pub divergence: Field, pub particles: Vec<...
true
9003f4c902aa87018f61927b10c35d8a41627f65
Rust
sparky8251/maelstrom
/src/server/handlers/registration.rs
UTF-8
3,815
2.796875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{db::Store, models::registration}; use actix_web::{ web::{Data, Json, Query}, Error, HttpResponse, }; use serde_json::json; /// Checks to see if a username is available, and valid, for the server. /// /// The server should check to ensure that, at the time of the request, the username /// requested ...
true
2a44eab8e166addb65b34b81a32f62eb5552dac1
Rust
Johnarry/rust-learning
/rust-begin/vector.rs
UTF-8
2,624
4.375
4
[]
no_license
// Vector is a re-sizable data structure, Vector allows you to store more than one value in a single data structure that puts all the values // next to each other in memory. Vector can only store value of the 👉 same type. // Vector is a generic type, written as 👉Vec<T> in which 👉T can be any type. // Create ...
true
324e07ffc2e983779421a54d5228ff389112e07b
Rust
Neopallium/fast-realworld-app
/src/services/mod.rs
UTF-8
2,995
2.8125
3
[ "MIT" ]
permissive
use log::*; use std::collections::HashMap; use actix_web::{web}; use crate::error::*; use crate::app::*; use crate::db::DbService; mod user; mod profile; mod article; mod tag; type BoxService = Box<dyn Service>; pub trait Service: ServiceClone + Send { /// Load Service config from AppConfig. fn load_app_confi...
true
7bfda62bd0d30c9a999ead61b08c36f8cd45db3e
Rust
IThawk/rust-project
/rust-master/src/test/ui/privacy/private-method.rs
UTF-8
392
3.203125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
mod kitties { pub struct Cat { meows : usize, how_hungry : isize, } impl Cat { fn nap(&self) {} } pub fn cat(in_x : usize, in_y : isize) -> Cat { Cat { meows: in_x, how_hungry: in_y } } } fn main() { let nyan : kitties::Cat = ...
true
4b61de66b4bea8f58096003512e72b2a2d5c04fe
Rust
ojensen5115/jwtcrack
/src/main.rs
UTF-8
5,691
2.703125
3
[]
no_license
extern crate crypto; extern crate rustc_serialize; extern crate time; use crypto::hmac::Hmac; use crypto::mac::Mac; use crypto::sha2::Sha256; use std::io::prelude::*; use rustc_serialize::base64::FromBase64; use std::sync::Arc; use std::sync::mpsc::{Sender, Receiver}; use std::sync::mpsc; use std::thread; use std:...
true
20f248877496677271104f88c7991165325c1292
Rust
ukabuer/path-tracer
/src/hitable.rs
UTF-8
1,971
3.171875
3
[]
no_license
extern crate rand; use super::{ray::Ray, vec3::Vec3, material::Material}; use std::rc::Rc; pub struct HitRecord { pub t: f32, pub p: Vec3, pub normal: Vec3, pub mat: Rc<Material>, } pub trait Hitable { fn hit(&self, r: &Ray, t_min: f32, t_max: f32) -> Option<HitRecord>; } pub type HitableList = Vec<Box<Hi...
true
45bba82e47fa7c9ee9d3365e691091b598959252
Rust
yepengding/MyPubEncryptor
/src/lib.rs
UTF-8
1,989
3.1875
3
[ "MIT" ]
permissive
use clap::{App, Arg}; mod config; pub mod cipher; pub mod utils; pub mod generator; /// Config struct that holds encryption information #[derive(Debug)] pub struct Config { pub file_path: String, pub filename: String, pub private_key: String, pub output_dir: String, } /// Initialize CLI pub fn init_c...
true
d58acdb00c9c7497e9e95804036b155c5ad9f12d
Rust
fanzier/raydiancy
/src/objects/sphere.rs
UTF-8
1,456
3.15625
3
[]
no_license
use basic::*; use objects::surface::*; /// Representation of a sphere. pub struct Sphere { pub center: Vec3, pub radius: f64, pub material: Material, } impl Surface for Sphere { fn intersect<'a>(&'a self, ray: &'a Ray, t_max: f64) -> Option<DelayedIntersection> { let x = ray.origin - self.cent...
true
176e84b1b24662b03fecf1821389456bd5c3e6e8
Rust
Turbo87/ogn-web-gateway
/src/ogn/time.rs
UTF-8
1,984
3.1875
3
[ "Apache-2.0", "MIT" ]
permissive
use chrono::*; pub fn time_to_datetime(now: DateTime<Utc>, time: NaiveTime) -> DateTime<Utc> { let now = now.naive_utc(); let datetime = now.date().and_time(time); let dt = now - datetime; DateTime::<Utc>::from_utc( if dt.num_hours() <= -12 { datetime - Duration::days(1) } ...
true
be226f24a09da467c80f7a2aed1f92d7b8f40764
Rust
Cahu/icmp-transfer
/src/odp.rs
UTF-8
7,127
2.609375
3
[]
no_license
use std::io; use std::cmp; use std::result; use std::rc::Rc; extern crate mio; use self::mio::*; use self::mio::unix::EventedFd; extern crate byteorder; use self::byteorder::{ByteOrder, LittleEndian}; extern crate icmp_communicator; use self::icmp_communicator::*; const TYPE_SND: u8 = 'S' as u8; // new packet cons...
true
8e5ecd27a196b6758a2765ce3f7269d86805a846
Rust
NicoAiko/demo-game
/src/snake.rs
UTF-8
8,133
2.90625
3
[]
no_license
use ggez; use rand; use ggez::event::{KeyCode, KeyMods}; use ggez::{event, graphics, Context, GameResult}; use std::collections::LinkedList; use std::time::{Duration, Instant}; use rand::Rng; const GRID_SIZE: (i16, i16) = (30, 20); const GRID_CELL_SIZE: (i16, i16) = (32, 32); const SCREEN_SIZE: (f32, f32) = ( G...
true
107936fb65a19e698512a365287a5be5e0cc55b1
Rust
Vlad-Shcherbina/icfpc2020-tbd
/src/parse_image.rs
UTF-8
7,281
3.25
3
[]
no_license
use crate::img_matrix::{ImgMatrix, FrameInfo}; use crate::img_matrix::Coord; use std::{fmt::Display, collections::HashMap}; #[derive(Debug, PartialEq, Eq)] pub enum Token { Integer(i64), Squiggly(String), Variable(i64), Operation(String), Unknown(usize), // id in list of unknown tokens Omissi...
true
04af1fa9cc14b411da5f19f1c2d11ccc91f22ae8
Rust
sria91-rlox/rust-lox-1
/src/treewalk/function.rs
UTF-8
2,828
3.25
3
[]
no_license
use super::constants::THIS_STR; use super::environment::Environment; use super::errs::{Error, RuntimeResult}; use super::interpreter::Interpreter; use super::object::Object; use crate::frontend::ast; use std::fmt; use std::rc::Rc; struct LoxFunctionData { fn_data: ast::FunctionDecl, is_initializer: bool, ...
true
6fb7638f43b4f2d7079115972c83d33543974534
Rust
ytyaru/Rust.Regex.20190729131335
/src/3/regex_hello/src/main.rs
UTF-8
358
2.8125
3
[ "CC0-1.0" ]
permissive
/* * Rustで正規表現(regex)。 * CreatedAt: 2019-07-29 */ use regex::Regex; fn main() { const CONTENTS: &'static str = r#"AAA 2019-07-29 BBB CCC 2019-07-30 DDD"#; let re = Regex::new(r"(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})").unwrap(); let result = re.replace_all(CONTENTS, ""); prin...
true
e230a180ca357ef91cd850ca355dcf1beea8b748
Rust
qy3u/leetcode-rs
/src/dp/counting_bits.rs
UTF-8
216
2.90625
3
[]
no_license
// qeustion 338 pub fn count_bits(num: i32) -> Vec<i32> { let mut result = vec![0; num as usize + 1]; for i in 1..=num { result[i as usize] = (i & 0x1) + result[(i / 2) as usize]; } result }
true
11b6edb95a40623aa2ad90cb6b5ff1f8a60da3bd
Rust
npmccallum/ipvlan
/src/netlink/interface.rs
UTF-8
8,088
2.53125
3
[]
no_license
// SPDX-License-Identifier: Apache-2.0 use super::{connection::Connection, Address, Error}; use netlink_packet_route::*; use std::convert::TryFrom; use std::io::ErrorKind; use std::net::IpAddr; use std::os::unix::io::AsRawFd; #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct Interface { index: u32, al...
true
623a249b498fc5c2e8c9f8f28326a2aa8e9e7d47
Rust
kcalvinalvin/rustreexo
/src/accumulator/pollard.rs
UTF-8
14,910
3.0625
3
[ "MIT" ]
permissive
// Rustreexo use std::collections::HashMap; use std::mem; use super::{ types, util, transform }; use bitcoin::hashes::{sha256, Hash, HashEngine}; /// Pollard is the sparse representation of the utreexo forest /// It is a collection of multitude of trees with leaves that are /// power of two. /// /// How...
true
a7603abacff25fd4435e93a6838bffba0821d5d7
Rust
tspooner/rstat
/src/univariate/beta_binomial.rs
UTF-8
3,573
2.828125
3
[ "MIT" ]
permissive
use crate::{ statistics::UvMoments, utils::*, DiscreteDistribution, Distribution, Probability, Univariate, }; use rand::Rng; use spaces::intervals::Closed; use special_fun::FloatSpecial; use std::fmt; pub use crate::params::{Count, Shape}; params! { #[derive(Copy)] Params { n: ...
true
932c629a6deaadd93ef89bb7c7bdd3c3dea57d36
Rust
phansch/rust-clippy
/clippy_utils/src/source.rs
UTF-8
15,080
3.078125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Utils for extracting, inspecting or transforming source code #![allow(clippy::module_name_repetitions)] use crate::line_span; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LintContext}; use rustc_span::hygiene; use rustc_span::{BytePos, Pos, Span, SyntaxContext}; ...
true
c18689afece637f5df055eba6f10fe4af7478c1f
Rust
bigdatajim2020/nibble
/src/storage.rs
UTF-8
5,516
2.515625
3
[]
no_license
use crate::block; use crate::crypto; use crypto::key; use rocksdb::{DB}; use serde_json; use std::collections::HashMap; use std::str::FromStr; pub mod db { use rocksdb::{DB, Options}; use crate::settings; static BLOCKS_DB_PATH: &str = "/blocks"; static BLOCKS_METADATA_DB_PATH: &str = "/blocksmeta...
true
3fa38a95e36ea0079aee404e5e506eab01450c5f
Rust
ir77/leran_rust
/IfLet/src/main.rs
UTF-8
312
3.515625
4
[]
no_license
fn main() { println!("Hello, world!"); let number: Option<i32> = Some(5); if number.is_some() { println!("{}", number.unwrap()); } if let Some(number) = number { // 上よりこっちのほうが良い。極力強制unwrapはしたくない。 println!("{}", number); } }
true
86a24590d4d1b9b99ce2028e0e210c50453e05d0
Rust
Cheshulko/Algorithms
/Leetcode/BiweeklyContest104/MaximumOR.rs
UTF-8
1,425
2.765625
3
[]
no_license
// https://leetcode.com/contest/biweekly-contest-104/problems/maximum-or/ impl Solution { pub fn maximum_or(nums: Vec<i32>, k: i32) -> i64 { let mx = nums .iter() .map(|x| (*x as f64).log2() as i64) .max() .unwrap(); let mx = 2_u64.pow(mx as u32) as ...
true
b4ee0e779dc7365c8e9f3501f12f64f1dc8b2db5
Rust
vabc3/raft
/examples/a.rs
UTF-8
582
2.578125
3
[]
no_license
extern crate raft; use raft::Node; use std::env; fn main() { let mut node_id = 0; let args: Vec<String> = env::args().collect(); if args.len() == 2 { node_id = match args[1].parse() { Ok(n) => n, Err(_) => { println!("Input is not integer."); ...
true
47c15ed784dd9abca6870c920a2141b3bae914f3
Rust
sugyan/adventofcode
/2020/rust/day03/src/main.rs
UTF-8
1,641
3.484375
3
[]
no_license
use std::io::{BufRead, BufReader}; struct Solution { grid: Vec<Vec<bool>>, } impl Solution { fn new(inputs: &[String]) -> Self { Self { grid: inputs .iter() .map(|row| row.chars().map(|c| c == '#').collect()) .collect(), } } f...
true
ae584cba9673c48164bc28dabe22eb6f5fcf9edd
Rust
Tangresh/rust-gol
/src/widgets.rs
UTF-8
395
2.640625
3
[]
no_license
use conrod; use conrod::Sizeable; pub trait StandardButton: Sizeable { fn std_size(self) -> Self { self.w_h(200.0, 40.0) } fn std_height(self) -> Self { self.h(40.0) } } impl<'a> StandardButton for conrod::widget::toggle::Toggle<'a> {} impl<'a, Show> StandardButton for conrod::widget:...
true
04cd5ceb8902247d159b5d6d670b998c50493917
Rust
ekuecks/aoc2020
/day_10/src/main.rs
UTF-8
1,295
3.140625
3
[]
no_license
use std::collections::HashMap; use std::io::stdin; fn main() { let input = stdin(); let mut jolts = Vec::new(); loop { let mut buf = String::new(); input.read_line(&mut buf).unwrap(); if buf.is_empty() { break; } jolts.push(buf.trim().parse::<u64>().unwra...
true
0cba694cf03b32f6d467649d2d854c03fe9c1287
Rust
mnilsson/z80
/src/registers.rs
UTF-8
13,608
2.921875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::cpu::{Z80, ImmByte, ImmWord, RelOffset, Read8, Read16, Write8, Write16}; use crate::cpu::Mem; use crate::flags::Flag; use crate::bus::Bus; use crate::util::make_u16; use crate::times; use std::fmt; impl fmt::Display for Registers { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writ...
true
077385db93b7c74c48420ce0ef125938c4b32140
Rust
desweemerl/price-sniffer
/src/main.rs
UTF-8
2,660
2.6875
3
[ "MIT" ]
permissive
extern crate curl; extern crate ini; #[macro_use] extern crate log; extern crate simplelog; extern crate postgres; extern crate regex; extern crate rust_decimal; use config::ConfigParser; use db::Db; use errors::AppError; use http::HttpProcessor; use ini::Ini; use simplelog::{Config, LevelFilter, SimpleLogger}; use s...
true
c31a428d5f0f3ebd9afba119c7744a0e8a1880d8
Rust
samgans/rust_rtree
/src/main.rs
UTF-8
824
2.640625
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use rtree::nodes::{ChildrenType, RtreeNode, RtreeObject}; use rtree::geometries::{BoundingRectangle, RtreeGeometry}; fn main() { let bounding = BoundingRectangle::new((5, 6), (5, 6)); let bounding_root = BoundingRectangle::new((5, 6), (5, 6)); let mut root = Rtree...
true
ce286d7fd6990af9b7436092b1c6f1572df96ca2
Rust
jthelin/demikernel
/examples/tcp-close/args.rs
UTF-8
5,989
2.828125
3
[ "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. //====================================================================================================================== // Imports //==============================================================================================================...
true
8f11a7b2fde4c61b0a6f69d2a1a45d8c9faf9a5d
Rust
w4tson/advent-of-code-2018
/rust-solutions/src/day04/mod.rs
UTF-8
2,631
3.125
3
[]
no_license
mod part1; mod part2; #[cfg(test)] mod tests; use chrono::NaiveDateTime; use std::collections::HashMap; use chrono::Timelike; //[1518-11-01 23:58] Guard #99 begins shift //[1518-04-18 00:32] falls asleep #[derive(Debug)] pub struct Observation { time : NaiveDateTime, guard: i32, wake : Wake } #[derive(Pa...
true
8973e891d404ef455e152f68d3af18cdda71eeb8
Rust
zono/isucon11-qualify
/go/pkg/mod/github.com/isucon/isucon10-portal@v0.0.0-20201008112716-8c0b637e1bd8/supervisor/src/main.rs
UTF-8
4,045
2.515625
3
[ "MIT" ]
permissive
use isuxportal_supervisor::api; use isuxportal_supervisor::config::Config; use isuxportal_supervisor::worker::Worker; fn main() { env_logger::from_env(env_logger::Env::default().default_filter_or("info")).init(); let config = envy::prefixed("ISUXPORTAL_SUPERVISOR_").from_env::<Config>().unwrap(); let mut...
true
994a44c039922006b7457afe59597d3bdee4504c
Rust
strake/rel.rs
/src/ord.rs
UTF-8
1,698
3
3
[ "Apache-2.0", "MIT" ]
permissive
//! Ordering relations use core::cmp::Ordering; use core::cmp::Ordering::*; use eq::*; pub trait PartialOrderRelation<A: ?Sized>: PartialEquivalenceRelation<A> { fn partial_cmp(&self, &A, &A) -> Option<Ordering>; #[inline] fn less(&self, x: &A, y: &A) -> bool { Some(Less) == self.partial_cmp(x, y) } ...
true
29ac811b2677433240eafbd4fbf19c3b5607555e
Rust
dylanbraithwaite/cubical
/src/ast/terms/functions/lambda.rs
UTF-8
2,092
2.9375
3
[]
no_license
use std::fmt::{Display, Formatter, Error as FmtErr}; use crate::ast::traits::*; use crate::ast::{Term, Expr}; use crate::context::Context; use crate::interval::IntervalDnf; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Lambda { pub source_type: Box<Term>, pub body: Box<Term>, } impl Lambda { pub fn n...
true
8164c93c3067dba6185c1fa504f80eb081ed32c9
Rust
ellipticoin/moonshined
/ellipticoin_contracts/src/bridge/mod.rs
UTF-8
5,357
2.828125
3
[]
no_license
use crate::{ charge, contract::{self, Contract}, token::Token, }; use anyhow::{anyhow, Result}; use ellipticoin_macros::db_accessors; use ellipticoin_types::{ db::{Backend, Db}, Address, }; use num_bigint::BigUint; use serde::{Deserialize, Serialize}; use std::convert::TryInto; #[derive(Serialize, ...
true
a18e9a4216ce975751c8f344d35ede953c76cd88
Rust
qnnnnez/rs
/src/interpreter.rs
UTF-8
16,311
3.03125
3
[]
no_license
use std::rc::Rc; use std::collections::{BTreeMap, BTreeSet}; use std::fmt; use sexpr::{SExpr, SAtom}; #[derive(Debug)] pub enum Value { None, Integer(i64), Bool(bool), Char(char), Callable(Box<CallableValue>), } pub trait CallableValue { fn get_name(&self) -> Option<&str>; ...
true
5b6ddc8606f652b030492a7aea2d73d5f94ad142
Rust
ferrous-systems/imxrt1052
/src/pmu/misc0_tog/mod.rs
UTF-8
46,852
2.5625
3
[]
no_license
#[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::MISC0_TOG { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w...
true
69f87694d5d6654b9f8a775cd57d9d6322a837c2
Rust
spacejam/sled
/src/histogram.rs
UTF-8
7,790
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Copied from my historian crate. - Tyler Neely //! //! A zero-config simple histogram collector //! //! for use in instrumented optimization. //! Uses logarithmic bucketing rather than sampling, //! and has bounded (generally <0.5%) error on percentiles. //! Performs no allocations after initial creation. //! Uses R...
true
ebf2171e396b1a81dfe4b72b35589a1ffa2c4630
Rust
andrewflbarnes/advent-of-code-2020
/17/lib3d.rs
UTF-8
3,614
3.40625
3
[]
no_license
use std::fmt; pub struct State { domain: Vec<Vec<Vec<u8>>>, x_bound: usize, y_bound: usize, z_bound: usize, } impl State { pub fn new(init_state: Vec<String>, bound: usize) -> State { let extends = (bound + 1) * 2; let x_init = init_state[0].len(); let y_init = init_state....
true
7bdd37866f019b5850e9f05c76aa4c59430260ea
Rust
INDAPlus21/carlch-task-2
/Kant_Avstand/src/main.rs
UTF-8
1,121
3.609375
4
[]
no_license
use std::io; use std::io::prelude::*; use std::cmp::*; fn main() { // Get stream let stream = io::stdin(); // Seperate each number let mut lines = stream .lock() .lines() .map(|_line| _line .ok() ...
true
95135e694df17bfb8ca738cb91b81c3e202bbca1
Rust
awakecoding/webrtc-sctp
/src/stack/settings.rs
UTF-8
1,475
2.703125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[allow(dead_code)] pub struct SctpProtocolParameters { pub rto_initial: u64, pub rto_min: u64, pub rto_max: u64, pub max_burst: usize, pub rto_alpha: (u32, u32), pub rto_beta: (u32, u32), pub valid_cookie_life: u64, pub association_max_retrans: usize, pub path_max_retrans: usize, ...
true
b8c9b0bee42645dca916527f96bb67500321ab94
Rust
dennisss/dacha
/pkg/rpc/src/message.rs
UTF-8
2,485
3.078125
3
[ "Apache-2.0" ]
permissive
// Utilities for reading/writing the length prefixed message framing format. use std::io::Cursor; use common::bytes::Bytes; use common::errors::*; use common::io::{IoError, IoErrorKind, Readable}; const MESSAGE_HEADER_SIZE: usize = 5; pub struct Message { pub data: Bytes, /// Whether or not this message co...
true
2dcb2617ecfcd3e9378eb8ea87c88d531c2db4f1
Rust
Tubbles/rustyPixelGameEngine
/examples/extensiontestgfx2d.rs
UTF-8
2,983
2.96875
3
[]
no_license
use pge::*; use pge::gfx2d::{Transform2D, GFX2D}; use pge::v2d::V2d; use image::GenericImageView; struct GameState { spr: Sprite, total_time: f32, // todo: move???? list_events: Vec<String>, } impl State for GameState { fn on_user_create(&mut self) -> bool { true } fn on_user_update(&...
true
e68d4332927f97f43ff4d3bca4d9c4811a584bb2
Rust
esmaeilmirzaee/rust
/printing_values/src/main.rs
UTF-8
423
3.671875
4
[]
no_license
fn main() { println!("Hello, world!"); println!("My name is {} and I am {} years old.", "Esmaeil", 35); println!("3 + 2 = {}", 3 + 2); println!("{0} doesn't have a {2} and a {1}.", "Esmaeil", "dog", "cat"); println!("{first_name} {surname}", surname="Esmaeil", first_name="MIRZAEE"); println!("Bi...
true
1180721ac0c48e1db84fd394fb428b40555620c8
Rust
FiloSanza/chip8
/examples/disassembler.rs
UTF-8
567
2.6875
3
[]
no_license
use chip8::disassemble; use std::fs::File; use std::io::Read; fn run(buffer: &Vec<u8>) { let mut pc = 0x200; while pc < buffer.len() { let opcode: u16 = (u16::from(buffer[pc]) << 8) | u16::from(buffer[pc+1]); disassemble(opcode); pc += 2; } } pub fn main() { let mut file = Fil...
true
1a4c8e7d6e230ff88d8ce8f736abcb67bc2f2dae
Rust
zhao-lang/redis_hnsw
/src/hnsw/core_tests.rs
UTF-8
2,771
2.765625
3
[ "MIT" ]
permissive
use crate::hnsw::core::*; use crate::hnsw::metrics::euclidean; use std::sync::Arc; // use std::{thread, time}; #[test] fn hnsw_test() { let n = 100; let data_dim = 4; // index creation let mut index: Index<f32, f32> = Index::new("foo", Box::new(euclidean), data_dim, 5, 16); assert_eq!(&index.name,...
true
6a7b89f61e1a80ce4f2b1b5d9788d2549141e958
Rust
pokersu/termchat-wan
/src/bin/server.rs
UTF-8
5,270
2.71875
3
[ "Apache-2.0" ]
permissive
use message_io::node::{self, NodeHandler}; use message_io::network::{Endpoint, NetEvent, Transport}; use std::collections::HashMap; use termchat_wan::message::NetMessage; use clap::{App, Arg}; struct OnlineDb{ user_endpoint_dict: HashMap<String, Endpoint>, endpoint_user_dict: HashMap<Endpoint, String>, } im...
true
aae11e83fae714348fb20ecd51ea40fe239d7ae1
Rust
tock/book
/imix/src/components/crc.rs
UTF-8
1,330
2.640625
3
[ "MIT" ]
permissive
//! Component for CRC syscall interface on imix board. //! //! This provides one Component, CrcComponent, which implements a //! userspace syscall interface to the CRC peripheral (CRCCU) on the //! SAM4L. //! //! Usage //! ----- //! ```rust //! let crc = CrcComponent::new().finalize(); //! ``` // Author: Philip Levis ...
true
fd1619ea07bfb448c0675d1232812f733f2e2107
Rust
DerekCrosson/rust-raytracer
/src/scene.rs
UTF-8
1,728
3.328125
3
[]
no_license
// Structures to hold scene data. pub struct Color { pub red: f32, pub green: f32, pub blue: f32, } pub struct Sphere { pub center: Point, pub radius: f64, pub color: Color, } pub struct Scene { pub width: u32, pub height: u32, pub fov: f64, pub elements: Vec<Element>, pub light: Light, } pub ...
true
91b4c8fd39136a334e33dac5e2d1601822b517d7
Rust
shybyte/exercism-rust
/rna-transcription/src/lib.rs
UTF-8
741
3.015625
3
[]
no_license
#[derive(Debug, Eq, PartialEq)] pub struct RibonucleicAcid { data: String, } impl RibonucleicAcid { pub fn new(data: &str) -> Self { RibonucleicAcid { data: data.to_string() } } } #[derive(Debug, Eq, PartialEq)] pub struct DeoxyribonucleicAcid { data: String, } impl DeoxyribonucleicAcid { ...
true
385f538728b2d67519a1a4ae6efd7b472647bd1a
Rust
Nashenas88/coi-actix-sample
/src/routes/data.rs
UTF-8
1,318
2.65625
3
[]
no_license
use crate::dtos::data::DataDto; use crate::services::service::IService; use actix_web::web::{self, ServiceConfig}; use actix_web::{Error, HttpResponse, Responder}; use coi_actix_web::inject; #[inject] async fn get( id: web::Path<i64>, #[inject] service: Arc<dyn IService>, ) -> Result<impl Responder, Error> { ...
true
0265d159004bfa46cd46f8d37972b33929a255ee
Rust
nushell/nushell
/crates/nu-command/tests/commands/lines.rs
UTF-8
1,446
2.890625
3
[ "MIT" ]
permissive
use nu_test_support::{nu, pipeline}; #[test] fn lines() { let actual = nu!( cwd: "tests/fixtures/formats", pipeline( r#" open cargo_sample.toml -r | lines | skip while {|it| $it != "[dependencies]" } | skip 1 | first | split co...
true
3c78fffa55360f19d5754d8922dbe695aafd4593
Rust
benjaminch/advent-of-code
/2020/05/solution/src/main.rs
UTF-8
3,188
3.375
3
[]
no_license
use std::io::{self, Error, ErrorKind, Read, Write}; use std::str::FromStr; #[derive(Debug)] struct Seat { row: u32, column: u32, } impl Seat { fn new(row: u32, column: u32) -> Seat { Seat { row, column } } fn id(&self) -> u32 { (self.row * 8) + self.column } } impl FromStr fo...
true
0a4685d125d931bee7f6e92fec92fd868bd19db2
Rust
vinmay/rust-tryouts
/user_input.rs
UTF-8
275
3.25
3
[]
no_license
use std::io::BufferedReader; use std::io::println; use std::io; fn main() { println("Enter something:"); let mut reader = BufferedReader::new(io::stdin()); let input = reader.read_line().unwrap(); println("Something that you typed:"); println(input); }
true
ed56373c9f291a84796af6d1ab3a4d0ead6390a0
Rust
fabianschuiki/moore
/src/vhdl/scope.rs
UTF-8
3,994
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) 2016-2021 Fabian Schuiki //! Facilities to manage declarations and resolve names. #![deny(missing_docs)] use std::collections::{HashMap, HashSet}; use crate::common::errors::*; use crate::common::score::Result; use crate::common::source::Spanned; use crate::common::Verbosity; use crate::score::{De...
true
e11de82fd5f6bfa3851773925c165c3bb5061471
Rust
TrolledWoods/impl_twice
/src/lib.rs
UTF-8
8,078
3.671875
4
[ "MIT" ]
permissive
#![deny(rust_2018_idioms, clippy::all, clippy::pedantic)] #![no_std] //! A crate for avoiding code duplication for immutable and mutable types. //! //! # Reason for existance //! When writing rust programs, times come when you need two types, //! one immutable and one mutable. //! //! It is possible to remove this dup...
true
1e072685c1057f42582d7e6b0e73b85195ca9a5b
Rust
tomaka/acpi
/acpi/src/hpet.rs
UTF-8
1,800
2.90625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{sdt::SdtHeader, Acpi, AcpiError, GenericAddress, PhysicalMapping}; use bit_field::BitField; #[derive(Debug)] pub enum PageProtection { None, /// Access to the adjacent 3KB to the base address will not generate a fault. Protected4K, /// Access to the adjacent 64KB to the base address will no...
true
ce2e983471cd819112ba49eef4abe65edb7ab5c6
Rust
dtolnay-contrib/realia
/src/lib.rs
UTF-8
8,594
3.09375
3
[ "MIT" ]
permissive
//! Realia provides attribute macros for conditional compilation, //! analogous to `#[cfg(...)]` and `#[cfg_attr(...)]`. #![allow(clippy::needless_doctest_main)] extern crate proc_macro; mod attr; mod dep; mod expr; mod metadata; use crate::attr::Then; use crate::expr::Expr; use proc_macro::TokenStream; use proc_ma...
true
58739e99bbd228b8b5c80987484a1cea4078c897
Rust
awslabs/amazon-qldb-shell
/src/main.rs
UTF-8
1,267
2.625
3
[ "Apache-2.0" ]
permissive
use amazon_qldb_shell::{error::ShellError, run}; use anyhow::Result; use std::{env, process::exit}; #[tokio::main(flavor = "current_thread")] async fn main() { if let Err(e) = _main().await { if let Some(shell) = e.downcast_ref::<ShellError>() { match shell { ShellError::UsageEr...
true
c9e9d3344541ab12528ae272fcc266a851d82c22
Rust
tonygallotta/adventofcode-2020
/day7/src/main.rs
UTF-8
5,476
3.390625
3
[]
no_license
use regex::Regex; use std::collections::HashMap; use std::env; use std::fs; use std::io; use std::io::BufRead; use std::iter::FromIterator; use std::time::Instant; #[allow(dead_code)] #[derive(Eq, PartialEq)] struct Bag { color: String, allowed_bags: HashMap<String, u32>, } // PART 1: 235 // PART 2: 158493 fn...
true
12d5303d717824149a550ee3e7100a038e0179d1
Rust
codeworm96/hikari
/src/constant_texture.rs
UTF-8
337
3.296875
3
[]
no_license
use crate::texture::Texture; use crate::vec3::Vec3; pub struct ConstantTexture { color: Vec3, } impl ConstantTexture { pub fn new(c: Vec3) -> ConstantTexture { ConstantTexture { color: c } } } impl Texture for ConstantTexture { fn value(&self, _u: f64, _v: f64, _p: &Vec3) -> Vec3 { se...
true
b6a8a48046e051442f1ff5347022b3f224fedd0b
Rust
darshimo/CompetitiveProgramming
/aoj/rust/alds/alds1_9_c.rs
UTF-8
2,151
3.265625
3
[]
no_license
pub fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } pub fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }...
true
15308998a49437ba03003e4167767eae787169e4
Rust
Connicpu/project-euler-rs
/euler019/src/main.rs
UTF-8
424
2.890625
3
[ "MIT" ]
permissive
extern crate chrono; use chrono::{Datelike, Duration, TimeZone, UTC}; fn main() { let start = UTC.ymd(1901, 1, 6); // the first sunday of the 21st century let sundays = (1..) .map(|i| start + Duration::days(7 * i)) // incrementing by sundays .take_while(|d| d.year() <= 2000) // 20th century ...
true
bac35ecbac8486c1249c40209e7170b09732f7b9
Rust
nicholasyager/advent-of-code-2017
/day_07/src/main.rs
UTF-8
6,723
2.9375
3
[]
no_license
extern crate regex; use std::env; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::io::Write; use std::io::BufWriter; use std::collections::HashSet; use std::collections::HashMap; use regex::Regex; #[derive(Clone, Debug)] struct Branch { id: String, weight: u32, total_weight: u3...
true
0bbca4226176379d201ac8d74ae82d41503ddf1e
Rust
raffalevy/math_parser
/src/math_parser.rs
UTF-8
5,166
3.5625
4
[]
no_license
use std::fmt::{self, Display}; use std::error::Error; use std::str::FromStr; pub type MathParseResult = Result<f64, MathParseError>; pub type MathScanResult = Result<Vec<Token>, MathParseError>; pub fn eval(expr: &str) -> MathParseResult { let tokens = scan(expr)?; let mut parser = Parser::new(tokens); le...
true
0cf69f65908f1549761a4bb228911bb6c1413434
Rust
APiercey/mylalang
/tests/file_test.rs
UTF-8
479
2.609375
3
[]
no_license
mod common; use common::assert_eq; use myla::core::types::Types::{String as Str}; #[test] fn test_reading_a_file() { assert_eq( r#"(readfile "tests/helper_files/hello_world.txt")"#, Str("Hello, World!\n".to_string()), ); } #[test] fn test_def_content_of_file() { assert_eq( r#" ...
true
e6e637b98921e9c2ca2caff9a2f2e671d8de503d
Rust
xujihui1985/learningrust
/rust-base/src/utils/direntry_froms.rs
UTF-8
355
2.84375
3
[]
no_license
use std::fs::DirEntry; use crate::prelude::*; impl TryFrom<W<&DirEntry>> for String { type Error = Error; fn try_from(value: W<&DirEntry>) -> Result<Self> { value .0 .path() .to_str() .map(String::from) .ok_or_else(|| Error::Generic(f!("inva...
true
7eb7c315b6f97835cee919f4203bdbe458601c6f
Rust
lyricwulf/include_optional
/examples/include_bytes_optional.rs
UTF-8
620
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
use include_optional::include_bytes_optional; #[derive(Debug)] struct Metadata { foo: &'static str, do_bar: bool, baz_count: u32, } static DEFAULT_METADATA: [u8; 4] = [0xAB, 0xAD, 0x1D, 0xEA]; fn main() { let metadata_file_exists: &[u8] = include_bytes_optional!("./metadata_files/file_exists....
true
55473b282b3b54e59d1a1683517c44739aba5222
Rust
rlay-project/rquantiles
/src/lib.rs
UTF-8
1,332
2.640625
3
[]
no_license
extern crate rustr; use std::fmt::{self, Debug}; use rustr::feature::engine::*; use rustr::rdll::unix64::SEXP; #[derive(Debug, Clone)] pub struct Quantiles { // 25th pub lower: f64, // 50th pub median: f64, // 75th pub upper: f64, } pub struct RList<'a, T: Debug + 'a>(&'a [T]); impl<'a, T: D...
true
10b22c08278bbb7c186d6baa6850fc255461e2f1
Rust
mongodb/bson-rust
/src/bson.rs
UTF-8
35,522
2.5625
3
[ "MIT" ]
permissive
// The MIT License (MIT) // Copyright (c) 2015 Y. T. Chung <zonyitoo@gmail.com> // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the righ...
true
a1679023aee15b24b61f8fce05b55beb2eb6a96f
Rust
voidpumpkin/tik-giphy
/backend/src/views/error_res_body.rs
UTF-8
1,122
2.890625
3
[]
no_license
use crate::constants::TITLE; use serde::{Deserialize, Serialize}; use serde_json::json; use validator::ValidationErrors; #[derive(Debug, Serialize, Deserialize)] pub struct ErrorResBody { pub errors: Vec<serde_json::Value>, } impl ErrorResBody { pub fn new_single_error(err: &str) -> ErrorResBody { Err...
true
d6b05f33bf4bd99f317884009764b69afbfebcb1
Rust
theduke/rust
/src/test/compile-fail/E0375.rs
UTF-8
926
2.5625
3
[ "MIT", "NCSA", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-3-Clause", "BSD-2-Clause", "Unlicense", "LicenseRef-scancode-other-permissive" ]
permissive
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
true
2818a79f0e9cb8ab11dcdd1385cc1ab41d9f8ee2
Rust
SPIGS/Polymorph
/src/components/gui.rs
UTF-8
1,831
2.8125
3
[ "MIT" ]
permissive
use specs::{Component, VecStorage, DenseVecStorage}; use bracket_lib::prelude::{Rect, Point}; #[derive(Debug, Copy, Clone)] pub enum Justification { RIGHT, LEFT, CENTER, FREE, } #[derive(Component, Debug)] #[storage(VecStorage)] pub struct Panel { pub bounds : Rect, pub decorations : bool, ...
true
26fb0890b24daaa4670133ecfe5397ed921cfece
Rust
nyeogmi/kupo
/src/frontend/parser/expression.rs
UTF-8
3,812
2.765625
3
[]
no_license
use crate::frontend::lexer::{Grouping, Operator, Token}; use super::error_helpers::kpe; use super::grouping_helpers::DelimitedMany; use super::{Parse, Parser}; use super::internal_ast::*; impl<'a> Parser<'a> { pub fn parse_expression(&mut self) -> Parse<ASTExpression> { let mut leaf = self.parse_leaf_exp...
true
7f5a911e8d18fa07c89242b7dba5c53e8dad6d81
Rust
gong023/rust-tutorial
/methods_basic.rs
UTF-8
446
3.4375
3
[]
no_license
struct Monster { attack: int, defence: int } impl Monster { fn print_attack(&self) { println!("attack is {}", self.attack); } fn print_defence(&self) { println!("defence is {}", self.defence); } fn print_num(num: int) { println!("{}", num); } } fn main() { ...
true
d5c658a23bca4e2f6d702426611ccda12466eb6f
Rust
joseluis/spaceindex
/spaceindex/src/rtree/tests.rs
UTF-8
1,030
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
use test::Bencher; use rand::Rng; use crate::geometry::IntoRegion; use crate::rtree::RTree; #[bench] fn bench_large_tree_lookups(b: &mut Bencher) { let mut rng = rand::thread_rng(); // generate 20,000 regions and insert them into our tree let mut tree = RTree::new(2); for _ in 0..200_000 { ...
true
87d0da6703320eb51defc4f0ac23f442fe5eef97
Rust
mrlhumphreys/salieri
/src/checkers_controller.rs
UTF-8
4,839
3.015625
3
[]
no_license
use std::env; use actix_web::HttpResponse; use super::checkers; pub fn opening(game_data: &String) -> HttpResponse { match checkers::openings::recommended_move(game_data) { Some(m) => HttpResponse::Ok().body(format!("{}\n", m)), None => HttpResponse::NotFound().body("404 Not Found\n") } } pu...
true
433d610b838a1056b9f868a3a8368a0c4d51f26f
Rust
tolumide-ng/Data-Structures-and-Algorithms
/algo_toolbox/src/divide_and_conquer/closest_point.rs
UTF-8
4,904
3.015625
3
[]
no_license
mod closest_point { use crate::divide_and_conquer::merge_sort_for_closest_point::merge_sort_module::merge_sort; use crate::divide_and_conquer::struct_defs::{Pair, SortBy, T}; fn closest_point_caller(list: &mut T) -> f32 { let list_length = list.len() - 1; let mut list_for_y = list.clone(); ...
true
e77e999326aba5d78ce7e8f249113bb5a0aa4aea
Rust
vaheqelyan/gl-event-reducer
/src/font.rs
UTF-8
26,981
3.09375
3
[]
no_license
use std::collections::HashMap; #[derive(Debug)] pub struct Char { pub width: f32, pub height: f32, pub originX: f32, pub originY: f32, pub advance: f32, pub path: String, pub layer: usize, } pub fn get_font() -> HashMap<String, Char> { let mut char_list = HashMap::new(); char_list....
true
37f81cde9b09842d6260944f2d045af32a4c8a39
Rust
Soru321/rust-yew-realworld-example-app
/swapi_ios/src/ffi/ios_ffi.rs
UTF-8
2,320
2.546875
3
[ "MIT" ]
permissive
use std::ffi::CString; use std::os::raw::{c_char, c_void}; use super::native_model::{PeopleNative, PeopleNativeWrapper}; use swapi_core::swapi::{SwapiClient}; use std::ops::Deref; use super::callback::{Callback}; //Create client #[no_mangle] pub extern "C" fn create_swapi_client() -> *mut SwapiClient { Box::into_r...
true
0ba4f67b0f7e3d77bf5da0cefe5b2ada4f71ed9d
Rust
richo/commavm
/src/analysis.rs
UTF-8
3,045
3.078125
3
[]
no_license
use syntax::ast; pub type Name = String; pub fn locals(blk: &ast::Block) -> Vec<Name> { let mut locals = Vec::new(); for stmt in &blk.stmts { // TODO Other types of decl if let ast::StmtDecl(ref decl, ref id) = stmt.node { if let ast::DeclLocal(ref n) = decl.node { ...
true
e16a64e8b47328a57835012caf0a9350b9fa27c1
Rust
socialdash/notifications
/src/controller/routes.rs
UTF-8
3,286
2.84375
3
[]
no_license
use std::str::FromStr; use stq_router::RouteParser; use stq_static_resources::TemplateVariant; use stq_types::*; /// List of all routes with params for the app #[derive(Clone, Debug, PartialEq)] pub enum Route { SimpleMail, OrderUpdateStateForUser, OrderUpdateStateForStore, OrderCreateForUser, Ord...
true
65514c3000a7a01c39412a3923d7f9b850f532e6
Rust
a1967629423/vue-compiler
/crates/sfc/src/rewrite_default.rs
UTF-8
840
2.5625
3
[ "MIT" ]
permissive
pub fn rewrite_default(input: String, _as_var: &'static str) -> String { if !has_any_default_export(&input) { return input; } todo!() } /* const defaultExportRE = /((?:^|\n|;)\s*)export(\s*)default/ const namedDefaultExportRE = /((?:^|\n|;)\s*)export(.+)as(\s*)default/s const exportDefaultClassRE =...
true
4ef5916fd2006191c5d7e140d2001e9257ccc967
Rust
chimon2000/derry
/native/src/lib.rs
UTF-8
1,434
2.59375
3
[ "MIT" ]
permissive
extern crate colored; extern crate ctrlc; extern crate shared_child; use colored::*; use shared_child::SharedChild; use std::ffi::CStr; use std::os::raw::c_char; use std::process::Command; use std::sync::Arc; #[no_mangle] pub extern "C" fn executor(ptr: *const c_char) -> i32 { let c_str = unsafe { CStr::from_ptr(p...
true
657ee35ef053ec4c22de476474f133bab69349b4
Rust
vksmgr/rust-exorcism
/nth-prime/src/lib.rs
UTF-8
1,144
3.46875
3
[]
no_license
#[derive(Debug, PartialEq)] pub struct Error<T> { msg: T, } // brute force fn __is_prime(n: i32) -> bool { if n < 2 { return false; } for y in (2..n).rev() { if n % y == 0 { return false; } } return true; } // AKS (?) fn is_prime(n: i32) -> bool { if n <...
true
e95c7954365b2d8b378b1826d3da2acad4fbe5e7
Rust
Atul9/osmgraphing
/src/osm/parser.rs
UTF-8
1,290
2.875
3
[ "Apache-2.0" ]
permissive
use std::ffi::OsStr; use super::Reader; pub struct Parser; impl Parser { pub fn parse<S: AsRef<OsStr> + ?Sized>(&self, path: &S) { //----------------------------------------------------------------------------------------// // get reader let mut reader = Reader::from_path(&path).unwrap()...
true
fdaf121b32092f50903e7475e20f92cd7f7f4607
Rust
tari-project/tari
/common/src/configuration/bootstrap.rs
UTF-8
6,621
2.625
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2022 The Tari Project // SPDX-License-Identifier: BSD-3-Clause use std::{ fmt, fmt::{Display, Formatter}, io, path::Path, str::FromStr, }; use super::error::ConfigError; use crate::configuration::Network; pub fn prompt(question: &str) -> bool { println!("{}", question); let m...
true
2446a651ddbe21276d22cc17f305d7691b105065
Rust
bazk/advent-of-code-2019-solutions
/day09/src/main.rs
UTF-8
1,054
3.125
3
[]
no_license
mod computer; use std::env; use computer::{Computer, Interruption}; #[allow(dead_code)] fn part1(filename: &str) { let mut computer = Computer::new(); computer.flash(filename); computer.input(1); println!("running in test mode..."); loop { match computer.run() { Interruptio...
true
95529be17298fb5e8f698b09f482a1f4335f2c3a
Rust
isgasho/second_opinion
/src/mmb/stmt.rs
UTF-8
2,830
3.15625
3
[]
no_license
/// `STMT_AXIOM = 0x02`, starts an `axiom` declaration pub const STMT_AXIOM: u8 = 0x02; /// `STMT_SORT = 0x04`, starts a `sort` declaration pub const STMT_SORT: u8 = 0x04; // `STMT_TERM = 0x05`, starts a `term` declaration //pub const STMT_TERM: u8 = 0x05; /// `STMT_DEF = 0x05`, starts a `def` declaration. (This is th...
true
dd9d87595c404cb66313a03d852086423ebe462f
Rust
WuerthPhoenix/tornado
/common/api/src/partial_ordering.rs
UTF-8
3,700
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::cmp::Ordering; use num_cmp::NumCmp; use serde_json::{Number, Value}; pub trait PartialOrdering<Rhs: ?Sized = Self>: PartialEq<Rhs> { fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>; #[inline] fn lt(&self, other: &Rhs) -> bool { matches!(self.partial_cmp(other), Some(Ordering::Less...
true