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
b4b8b2f8aada00e322f5b95c9a06b3832caa8ea6
Rust
memoherreraacosta/rust_fundations
/function.rs
UTF-8
204
3.1875
3
[]
no_license
fn main(){ //println!("Hello"); another_func(54); println!("foo sum: {}", foo(5,5)); } fn another_func(x: i32){ println!("foo ran x = {}", x); } fn foo(x:i32, y:i32) -> i32{ x + y }
true
9e73cfb164928cf9c295ae5efb45bfd0fd7e3996
Rust
swlody/advent-2019-rs
/src/day5.rs
UTF-8
556
2.640625
3
[]
no_license
use crate::intcode::Program; #[aoc_generator(day5)] fn input_generator(input: &str) -> Vec<i64> { input .trim() .split(',') .map(|x| { x.parse() .unwrap_or_else(|_| panic!("Unable to parse \"{}\" as integer", x)) }) .collect() } #[aoc(day5, part1...
true
92c146a09ed7de257462ce59367d58ea45fc4d0a
Rust
shengLin-alex/rust-exercise
/string/src/main.rs
UTF-8
1,752
4.1875
4
[]
no_license
fn main() { let str1 = String::new(); let s = "initial content"; let s2 = s.to_string(); let s3 = "initial content".to_string(); // true println!("{}", s2 == s3); // all utf-8 let hello = String::from("السلام عليكم"); let hello = String::from("Dobrý den"); let hello = String::...
true
e64335700ebe6279f9673dc8c7a4d4755d5fbbab
Rust
swbae31/repair-script-library
/src/linux/common/helpers/alar2/src/mount.rs
UTF-8
3,625
2.828125
3
[ "MIT", "LicenseRef-scancode-generic-cla" ]
permissive
use crate::helper; use crate::constants; use std::{fs, io, process}; //use sys_mount; pub(crate) fn mkdir_assert() -> Result<(), io::Error>{ match fs::create_dir_all(constants::ASSERT_PATH) { Ok(()) => Ok(()) , Err(e) => {println!("Error while creating the assert directory: {}", e); E...
true
98f0d3c68748517ce6f016362bc138ed80919aa2
Rust
tweedegolf/blue_hal
/src/hal/flash.rs
UTF-8
4,347
2.9375
3
[ "MIT" ]
permissive
use crate::utilities::memory::Address; use core::{ mem::{size_of, MaybeUninit}, slice, }; /// Reads and writes a range of bytes, generic over an address pub trait ReadWrite { type Error: Clone + Copy + Copy; type Address: Address; /// An identifying name for the flash chip. fn label() -> &'sta...
true
38cb7b64511eabe7565e6c8f2eae5681e68e85b5
Rust
I3ck/rust-3d
/src/kd_tree.rs
UTF-8
12,539
2.640625
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
/* Copyright 2016 Martin Buck Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublice...
true
55699fc8792daab8d62e8368661e6ad54ea7f27d
Rust
ein-lang/core
/ffi/src/number.rs
UTF-8
315
2.765625
3
[ "Apache-2.0" ]
permissive
#[no_mangle] extern "C" fn _ein_convert_number_to_string(number: ffi::Number) -> ffi::EinString { format!("{}", f64::from(number)).into() } #[cfg(test)] mod tests { use super::*; #[test] fn convert_to_string() { assert_eq!(_ein_convert_number_to_string(42.0.into()), "42".into()); } }
true
d76efdcfca641ad79ed2084122f1496b3c89b8b6
Rust
Trietptm-on-Security/seer
/src/cast.rs
UTF-8
5,290
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
use rustc::ty::{self, Ty}; use syntax::ast::{FloatTy, IntTy, UintTy}; use error::{EvalResult, EvalError}; use eval_context::EvalContext; use memory::{Pointer, SByte}; use value::PrimVal; impl<'a, 'tcx> EvalContext<'a, 'tcx> { pub(super) fn cast_primval( &self, val: PrimVal, src_ty: Ty<'tcx...
true
260c10e3bcec17f7bb29fa28fdc449daa8ad1cbd
Rust
sm-Fifteen/openmpt-rs
/src/module/ctls.rs
UTF-8
11,626
2.796875
3
[]
no_license
//! Definitions for all types and methods used to set and query //! libopenmpt parameters for the loaded module use openmpt_sys; use super::Module; use std::str::FromStr; use std::os::raw::*; const LOAD_SKIP_SAMPLES:&str = "load.skip_samples"; const LOAD_SKIP_PATTERNS:&str = "load.skip_patterns"; const LOAD_SKIP_PLUG...
true
3b3da7263176cc12ab52bf17722b0ec0093c3284
Rust
stearnsc/rust-stripe-client
/src/api/charge.rs
UTF-8
7,912
2.71875
3
[]
no_license
use call_args::CallArgs; use hyper::header::Headers; use idempotency_header::IdempotencyKey; use model::{ApiList, Charge, Currency, Shipping, SourceType}; use std::collections::BTreeMap; use time_constraint::TimeConstraint; use super::ApiCall; use {Result, StripeClient}; #[derive(Debug)] pub struct CreateChargeCall<'a...
true
62f7e770dfa9567c141b8ae47c87834fdb69de15
Rust
Luminiscental/aoc2020
/src/day10.rs
UTF-8
1,647
3.140625
3
[]
no_license
use crate::day::Day; use std::iter; pub struct Day10 {} impl<'a> Day<'a> for Day10 { type Input1 = Vec<usize>; type Input2 = Vec<usize>; type Output1 = usize; type Output2 = usize; const INDEX: usize = 10; fn parse(raw_input: &'a str) -> Self::Input1 { let mut jolt_adaptors: Vec<_> =...
true
001f2490b1e26ef6d96876f628a604d00e96bf76
Rust
swc-project/swc
/crates/swc_common/src/pass.rs
UTF-8
693
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! This module reexports items from `swc_visit` with some swc-specific traits. use std::borrow::Cow; pub use swc_visit::*; /// A named compiler pass. pub trait CompilerPass { /// /// - name should follow hyphen-case. /// - an implementation should return same name fn name() -> Cow<'static, str>; } ...
true
6c86af3a78edf7b4056f729c6910e8b6cdafb157
Rust
sharkbound/rust-projects
/aoc/src/day1-part2/src/main.rs
UTF-8
489
3.4375
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::Read; fn get_fuel(mass: i64) -> i64 { let fuel = mass / 3 - 2; if fuel <= 0 { return 0; } fuel + get_fuel(fuel) } fn main() { let mut f = File::open("data.txt").expect("could not read data.txt"); let mut text = String::new(); f.read_to_string(&mut t...
true
fe4cd98b56f08d427ff12013d134c2ffdd379824
Rust
hjarrell/rust-hashing-analysis
/src/main.rs
UTF-8
4,797
2.609375
3
[]
no_license
extern crate rand; extern crate plotlib; use rand::prelude::*; use plotlib::scatter::Scatter; use plotlib::scatter; use plotlib::style::{Marker, Point}; use plotlib::view::View; use plotlib::page::Page; mod hashtable; use self::hashtable::HashTable as HashTable; use self::hashtable::OAHashTable as OAHashTable; use s...
true
336424fd15e8409efc50cd5884c2f101026527bb
Rust
arnau/pikt
/pikchr-sys/src/lib.rs
UTF-8
2,867
3.171875
3
[ "0BSD", "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! The raw bindings for `pikchr.c`. //! //! Using [`pikchr`] will require manually freeing the buffer. Quoting the C source code: //! //! > This file implements a C-language subroutine that accepts a string //! > of PIKCHR language text and generates a second string of SVG output that //! > renders the drawing defined...
true
0178c247548204eb190d128b342fe0509c4939ff
Rust
hinagis/abc194
/src/bin/b.rs
UTF-8
380
2.515625
3
[]
no_license
fn main() { proconio::input! { n: usize, ab: [(u32, u32); n] } let mut t = ab[0].0 + ab[0].1; for i in 0..n { let a = ab[i].0; for j in 0..n { let b = ab[j].1; t = t.min(if i == j { a + b } else { a.max(...
true
8564fe55283660c7a9485132eee3d8012648930a
Rust
jlgerber/jobsyspolice
/src/jspt/statemachine.rs
UTF-8
7,405
3.34375
3
[]
no_license
use nom::{IResult}; use crate::jspt::{ParseResult, Header, start_parser, regex_parser, node_parser, edge_parser, JSPTemplateError, JSPTemplateLineError}; use std::cell::Cell; use std::fmt; /// The states that the StateMachine may transition through, from the start (Start) /// to the two possible terminal states (Done,...
true
897843b90fff85d10690482b1c4de62c57f02987
Rust
binyomen/rusteuler
/src/problem_11.rs
UTF-8
8,350
2.765625
3
[]
no_license
//! > In the 20×20 grid below, four numbers along a diagonal line have been //! marked in red. //! > //! > 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 \ //! 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 \ //! 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 \ //! 52 70 95 23 04 ...
true
c8311dbf73f22a374190eaf81f87ae037c0ad6b3
Rust
fkoep/intern-rs
/src/intern.rs
UTF-8
2,641
2.96875
3
[ "MIT" ]
permissive
use pool::Pool; use std::ffi::{CStr, CString, OsStr, OsString}; use std::path::{Path, PathBuf}; pub trait Intern { type Interned: 'static; fn intern(self) -> &'static Self::Interned; } lazy_static!{ static ref STR_POOL: Pool<str> = Pool::new(); static ref C_STR_POOL: Pool<CStr> = Pool::new(); stat...
true
ca7bc2439dcd8045ecded014d9fc82ac2c2cfb65
Rust
luminaryphi/keymaker
/src/contract.rs
UTF-8
3,380
2.53125
3
[ "Apache-2.0" ]
permissive
use cosmwasm_std::{Api, Binary, Env, Extern, HandleResponse, InitResponse, Querier, StdError, StdResult, Storage, to_binary}; use crate::msg::{HandleMsg, InitMsg, QueryAnswer, QueryMsg}; use crate::state::{load, save, State}; use sha2::{Digest}; use x25519_dalek::{PublicKey, StaticSecret}; use std::convert::TryInto; ...
true
e0d61cbb304cedb7646a7c25888a6c9aa6def043
Rust
Rustops/dwarf_seeks_fortune
/dsf_editor/src/systems/preview_animation.rs
UTF-8
989
2.5625
3
[ "BlueOak-1.0.0" ]
permissive
use amethyst::{ core::math::Vector3, core::timing::Time, core::transform::Transform, ecs::prelude::{Join, Read, ReadStorage, System, WriteStorage}, }; use crate::components::PreviewGhostTag; use amethyst::core::num::FloatConst; /// Responsible for animating the cursor previews (IE the ghostly outline...
true
36fccd16bccae0261e43dc68170f7becd6956ba8
Rust
5l1v3r1/binsec
/src/bin/binsec.rs
UTF-8
2,614
2.796875
3
[ "MIT" ]
permissive
//! binsec.rs //! //! main cli entry point to binsec application. //! extern crate clap; extern crate term_table; extern crate colored; extern crate goblin; extern crate serde; extern crate binsec; use std::iter::Iterator; use clap::{Arg, App, AppSettings}; use colored::*; use binsec::{Detector, Format}; /// TO...
true
5a36e22d26a30a6de5a52ea817e15b36dab941ec
Rust
dizda/rustbar
/src/util.rs
UTF-8
413
3.3125
3
[]
no_license
use separator::Separatable; pub fn thousands(number: &String, decimal: usize) -> String { let number: f64 = number.parse().unwrap(); // Limit the number of decimals, this convert to string let number = format!("{:.*}", decimal, number); // To separate the thousands, separated_string needs a number, ...
true
39ba854842f1f58f05eb0cbf3a5bd3825348bb25
Rust
zbraniecki/l20n.rs
/tests/parser_test.rs
UTF-8
1,622
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate l20n; extern crate serde; extern crate serde_json; use std::io::prelude::*; use std::fs::File; use std::io; use std::fs; use l20n::ftl::entries::parser::Parser as EntriesParser; use l20n::ftl::entries::ast::Resource as EntriesResource; fn read_file(path: &str) -> Result<String, io::Error> { let mut ...
true
329cd7f92cf611ab9a07155d4db3776b742d8c5c
Rust
portier/portier-broker
/src/utils/rng.rs
UTF-8
1,640
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
use ring::rand::{SecureRandom as GeneratorTrait, SystemRandom}; use tokio::task::spawn_blocking; #[derive(Clone)] pub struct SecureRandom { pub generator: SystemRandom, } impl SecureRandom { pub async fn new() -> Self { let generator = SystemRandom::new(); let res = Self { generator }; ...
true
eb3458cc830ca70e5c78bb760fb0b7d953156559
Rust
Innomi/ITMO-HW
/Labs/Discr4.1/C/c.rs
UTF-8
1,329
2.734375
3
[]
no_license
use std::io::Write; use std::io; fn main() { let modul : i64 = 1_000_000_007; let stdin = io::stdin(); let k : u16; let m : u16; { let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); let mut iter = buf.trim().split_whitespace(); k = iter.n...
true
ae77bd2bf163ac5af2b25bdf72ca02e063d443c9
Rust
qwfy/dge
/dge-gen/src/error.rs
UTF-8
635
2.65625
3
[]
no_license
use askama; use thiserror; pub type Result<T> = std::result::Result<T, Error>; #[derive(Debug, thiserror::Error)] pub enum Error { // graph related errors #[error("Node is ill formed: {}", .node)] IllFormedNode { node: String }, #[error(transparent)] AskamaError(#[from] askama::Error), #[err...
true
85106de13a5241eb825661f33e3b4ea06aecb8a5
Rust
cjbassi/neotop
/src/draw.rs
UTF-8
1,884
2.671875
3
[ "MIT" ]
permissive
use tui::backend::Backend; use tui::layout::{Constraint, Direction, Layout, Rect}; use tui::{Frame, Terminal}; use crate::app::{App, Widgets}; pub fn draw_widgets<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) { terminal .draw(|mut frame| { let vertical_chunks = Layout::default() .direction(Directio...
true
3db720b125f8e417bbf09c3b8efd8eb25c2e4230
Rust
prisma/prisma-engines
/quaint/src/ast/index.rs
UTF-8
1,726
3.3125
3
[ "Apache-2.0" ]
permissive
use super::{Column, Table}; /// A definition of a database index. /// /// Used mainly for the transformation of a `INSERT` into a `MERGE`. #[derive(Debug, PartialEq, Clone)] pub enum IndexDefinition<'a> { Single(Box<Column<'a>>), Compound(Vec<Column<'a>>), } impl<'a> IndexDefinition<'a> { pub(crate) fn se...
true
2570f67c9e4aa1821d57d5fc6133e0c84f1dd1b6
Rust
raskr/rust-autograd
/src/optimizers/mod.rs
UTF-8
2,939
2.8125
3
[ "MIT" ]
permissive
//! A collection of gradient descent optimizers pub mod adagrad; pub mod adam; pub mod momentum_sgd; pub mod sgd; use crate::evaluation::Feeder; use crate::tensor::Tensor; use crate::variable::VariableNamespace; use crate::{Context, Float}; pub use adagrad::AdaGrad; pub use adam::Adam; pub use momentum_sgd::MomentumS...
true
792b54b9a540db5499032f9387fd91aa76e2aa1f
Rust
dbcfd/tls-async
/tests/bad.rs
UTF-8
4,078
2.625
3
[ "MIT" ]
permissive
use std::net::ToSocketAddrs; use cfg_if::cfg_if; use futures::FutureExt; use futures_tokio_compat::Compat; use tls_async::{Error, TlsConnector}; use tokio::net::TcpStream; fn check_cause(err: Error, s: &str) { assert!( err.to_string().contains(s), "Error {} did not contain {}", err, ...
true
12858b1dc1c2695210ca6ca2afbf0a213636d54f
Rust
vkstrm/ngo
/src/main.rs
UTF-8
2,449
2.875
3
[]
no_license
use clap::{App, Arg}; use kanji; fn main() { let matches = App::new("ngo") .subcommand(App::new("kana") .about("Transform text into kana") .arg( Arg::new("input") .about("Input to transform") .required(true) ...
true
29902b39f4c6aad0ea255d1b765a623dedea87e1
Rust
cds-astro/cds-moc-rust
/src/moc/range/op/merge.rs
UTF-8
3,837
3.046875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::ops::Range; use std::vec::IntoIter; use crate::idx::Idx; use crate::qty::MocQty; use crate::moc::{HasMaxDepth, ZSorted, NonOverlapping, MOCProperties, RangeMOCIterator}; use std::marker::PhantomData; /// Build a range MOC from unordered, possibly overlapping ranges. /// WARNING: no degrade operation perform...
true
dfb281a0234b92a9556e2bcfe7ade8e619ba5a5d
Rust
wwjiang007/fuchsia
/src/developer/ffx/plugins/audio/utils/src/lib.rs
UTF-8
5,660
2.546875
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { anyhow::{Error, Result}, errors::ffx_bail, fidl_fuchsia_audio_ffxdaemon::*, hound::{WavReader, WavSpec}, std::{cmp, str::FromStr,...
true
f6ca93f19a5be5db699b4428774b80699aa4c06b
Rust
seventh-chord/gondola
/src/ui.rs
UTF-8
31,549
3.015625
3
[ "MIT" ]
permissive
//! Immediate mode gui. See [`ui::Ui`](struct.Ui.html) for more info. use std::mem; use gl; use gl::types::*; use std::ops::Range; use std::collections::HashMap; use std::fmt::Write; use cable_math::Vec2; use color::Color; use font::{Font, CachedFont}; use input::{InputManager, Key, KeyState}; use shader::{Shader, S...
true
126ed425b3e6fd7ab9cc457e8bb47fcef5670bbd
Rust
sigp/lighthouse
/common/lru_cache/src/time.rs
UTF-8
7,081
3.578125
4
[ "Apache-2.0" ]
permissive
//! This implements a time-based LRU cache for fast checking of duplicates use fnv::FnvHashSet; use std::collections::VecDeque; use std::time::{Duration, Instant}; struct Element<Key> { /// The key being inserted. key: Key, /// The instant the key was inserted. inserted: Instant, } pub struct LRUTimeC...
true
a2488a7173739c68602581e0f3d834b1baeb2c41
Rust
Emberwalker/honours-pas
/srv/rocket/lib/src/fairing/fairings.rs
UTF-8
4,001
3
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "ISC" ]
permissive
use {Rocket, Request, Response, Data}; use fairing::{Fairing, Kind}; #[derive(Default)] pub struct Fairings { all_fairings: Vec<Box<Fairing>>, attach_failure: bool, launch: Vec<&'static Fairing>, request: Vec<&'static Fairing>, response: Vec<&'static Fairing>, } impl Fairings { #[inline] p...
true
f50bb0064e9e4172332113778c0f3d765704f5b5
Rust
drogue-iot/drogue-async
/src/alloc/cortex_m/mod.rs
UTF-8
3,613
3.328125
3
[ "Apache-2.0" ]
permissive
//! A heap allocator for Cortex-M processors. //! //! Note that using this as your global allocator requires nightly Rust. //! //! # Example //! //! For a usage example, see `examples/global_alloc.rs`. mod alloc; use core::cell::RefCell; //use core::alloc::Layout; use core::ptr::NonNull; use alloc::layout::Layout; u...
true
72c1bfea6a74dc8d160bd68efa25bc2f44662ed4
Rust
yumetodo/romaji_kana_cvt_rust
/src/cvt.rs
UTF-8
8,404
2.671875
3
[ "BSL-1.0" ]
permissive
mod jis_x_4063_2000; extern crate unicode_normalization; use log::info; // use unicode_normalization::char::compose; use unicode_normalization::UnicodeNormalization; use std::collections::HashMap; use std::iter; #[derive(Debug)] pub struct RomajiCvt { from_romaji_table: [HashMap<&'static str, &'static st...
true
4b3167f3988871b3b991af4b59d59c55f1dbeee4
Rust
nicolasjhampton/rust-server-framework
/router/src/lib.rs
UTF-8
1,164
3.21875
3
[]
no_license
use http::{Request, Response, Method}; use std::net::TcpStream; pub struct Router { request: Request<TcpStream>, response: Response<TcpStream> } impl Router { pub fn new(stream: TcpStream) -> Router { let stream_copy = stream.try_clone().unwrap(); let request = Request::new(Box::new(strea...
true
29903a9418d6893cf5472e2d00c8d9a45e246fad
Rust
andrewimm/wasm-c64
/rust/lib/nes-memmap/src/controller.rs
UTF-8
1,833
3.6875
4
[]
no_license
pub struct Controller { pub a: bool, pub b: bool, pub select: bool, pub start: bool, pub up: bool, pub down: bool, pub left: bool, pub right: bool, latching: bool, latch: u8, } impl Controller { pub fn new() -> Controller { Controller { a: false, b: false, ...
true
28c7b5cac2e0e72c71156f5b6045c720fe9b733e
Rust
wilsoniya/rust_experimentation
/datagram_echo/src/echoer.rs
UTF-8
1,581
3.109375
3
[]
no_license
// use std::result::Result; // use std::net::UdpSocket; // use std::str::from_utf8; // use std::error::Error; // use std::convert::From; // use std::io::Error as IoError; // use std::str::Utf8Error; // // pub enum EchoError { // Io(IoError), // Utf(Utf8Error), // } // impl From<IoError> for EchoError { // f...
true
607a27d19cc167ce6394bbc89b3ffc1849852b60
Rust
ejmount/runvec
/src/iter.rs
UTF-8
3,290
3.671875
4
[ "MIT" ]
permissive
pub struct RunLengthIterator<T, Iter> where T: PartialEq, Iter: Iterator<Item = T>, { iter: Iter, current: Option<T>, count: usize, } impl<T, Iter> RunLengthIterator<T, Iter> where T: PartialEq, Iter: Iterator<Item = T>, { pub fn new(iter: Iter) -> RunLengthIterator<T, Iter> { R...
true
5fd3cfb19e6ce25785194f8759553b7c92e65a0c
Rust
gefjon/zeldesque
/src/state/menu.rs
UTF-8
3,575
3.015625
3
[]
no_license
use opengl_graphics::glyph_cache::GlyphCache; use opengl_graphics::GlGraphics; use piston::input::{ButtonArgs, Key, UpdateArgs}; use graphics::math::Matrix2d; use piston::input::Key::*; use piston::input::Button::*; use piston::input::ButtonState::*; use keyboard::Keyboard; use super::{StateChangeRequest, Update}; co...
true
925416e16fb3b7beb68f13b60d631b76ab36f167
Rust
mlimat/connect4
/src/player/human.rs
UTF-8
1,347
3.453125
3
[]
no_license
pub struct Human<T> { token: T, } impl<T: std::fmt::Display + Copy> super::Player<T> for Human<T> { fn next_move(&self, available: &Vec<usize>, _: &Vec<Vec<T>>) -> usize { self.get_input(available).unwrap() } fn token(&self) -> T { self.token } } impl<T> super::PlayerBuilder<T> fo...
true
fbd54c1be8f898e722bcccf90d04afd4a766f3ef
Rust
mrillusi0n/rust-beginner
/tup.rs
UTF-8
189
3.109375
3
[ "MIT" ]
permissive
fn main() { let super_heroes = ("Super Man", "Spider Man"); let (super_man, spider_man) = super_heroes; println!("I'm {}!", super_man); println!("He's {}!", spider_man); }
true
de5e11e15ece0e5912473e49ea51d64fa9aba3e8
Rust
cedelmaier/rust-concurrent-hashmap
/examples/wordcount.rs
UTF-8
1,491
3.265625
3
[]
no_license
#![feature(scoped)] extern crate concurrent_hashmap; use std::cmp::max; use std::io::Read; use std::io; use std::thread; use std::default::Default; use concurrent_hashmap::*; fn main() { let words = read_words(); let word_counts: ConcHashMap<String, u32> = Default::default(); count_words(&words, &word_co...
true
3d25dae9a33191c6fdd3e7d8e377328e28fab2d2
Rust
Dizans/rbe
/src/ch6_conversion.rs
UTF-8
1,392
4.0625
4
[]
no_license
// From and Into use std::convert::From; #[derive(Debug)] struct Number{ value: i32, } // The Into trait is simply the reciprocal of the From trait. // That is, if you have implemented the From trait for your type // you get the Into implementation for free. impl From<i32> for Number{ fn from(item: i32) ->...
true
2d3870712a2ff6c906292a807bead26b9f0da7ae
Rust
jianantian/r4cppp
/graphs/src/ref_graph.rs
UTF-8
2,601
3.3125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::cell::UnsafeCell; use std::collections::HashSet; use std::collections::VecDeque; use typed_arena::Arena; struct Node<'a> { name: &'static str, edges: UnsafeCell<Vec<&'a Node<'a>>>, } impl<'a> Node<'a> { fn new<'b>(name: &'static str, arena: &'b Arena<Node<'b>>) -> &'b Node<'b> { arena.all...
true
dd7790c33b1134c1bd208ae3641e5fa79260ddba
Rust
santosh241/Windary
/Rust/src/0350_intersection_of_two_arrays_ii.rs
UTF-8
2,490
3.96875
4
[ "MIT" ]
permissive
//! Given two arrays, write a function to compute their intersection. //! //! ``` //! Example 1: //! //! Input: nums1 = [1,2,2,1], nums2 = [2,2] //! Output: [2,2] //! ``` //! //! ``` //! Example 2: //! //! Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] //! Output: [4,9] //! ``` //! //! Note: //! //! Each element in the re...
true
95f4e1d4305e3b57f9a50dd4d37335fe8c75d222
Rust
EFanZh/LeetCode
/src/problem_0232_implement_queue_using_stacks/double_ended_stack.rs
UTF-8
1,495
3.40625
3
[]
no_license
// ------------------------------------------------------ snip ------------------------------------------------------ // pub struct MyQueue { front: Vec<i32>, back: Vec<i32>, } impl MyQueue { fn new() -> Self { Self { front: Vec::new(), // Invariant: if the stack is non-empty, `front` ...
true
1665a1419c5ea963ae2b159e0c5622d923d49f0f
Rust
quahad/bopolyri
/src/var.rs
UTF-8
1,572
3.390625
3
[]
no_license
use std::cmp::Ordering; use std::fmt::{self, Display}; #[derive(Debug, Clone, Copy)] pub enum AssociatedVariableType { NoType, L(usize, usize, usize), K(usize), X(usize, usize), Y(usize, usize), } #[derive(Debug)] pub struct Variable { name: String, order: usize, associated_type: Associ...
true
89d0888e5612b787993b582790bd9b157d7826c4
Rust
CraZySacX/aoc
/src/year2015/day13.rs
UTF-8
438
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Advent of Code - Day 13 Solution use anyhow::Result; use std::io::BufRead; /// Find the solution pub fn find_solution<T: BufRead>(reader: T, _second_star: bool) -> Result<u32> { for line_result in reader.lines() { let _line = &line_result.unwrap_or_else(|_| "".to_string()); } Ok(0) } #[cfg(tes...
true
4b4c2cea4cfa1bcb5dc2e6b7a32ecfd752077f49
Rust
Vicfred/codeforces-rust
/word.rs
UTF-8
489
3.328125
3
[ "BSD-3-Clause" ]
permissive
// https://codeforces.com/problemset/problem/59/A use std::io; fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let s = s.trim(); let mut upper = 0; let mut lower = 0; for ch in s.chars() { if ch.is_lowercase() { lower += 1; } else {...
true
fc5d7791c82f3aa947c61cbb82065beb10604b21
Rust
kielSDeM/Rust-Web-Programming
/Chapter08/mapping_our_layers/src/views/users/create.rs
UTF-8
1,041
2.609375
3
[ "MIT" ]
permissive
use crate::diesel; use diesel::prelude::*; use actix_web::{web, HttpResponse}; use crate::database::establish_connection; use crate::json_serialization::new_user::NewUserSchema; use crate::models::user::new_user::NewUser; use crate::schema::users; /// This view creates a user and saves it in the state.json file. //...
true
e055173f5bf039b864f291dad8d655cbd32e1633
Rust
chainal/learn-rust
/src/learn_lib/prog_4_1.rs
UTF-8
1,236
4.09375
4
[]
no_license
pub fn action() { let s = String::from("hello"); // s进入作用域 takes_ownership(s); // s的值移动到函数里 // 所以这里不再有效 let x = 5; // x进入作用域 makes_copy(x); // x应该移动到函数里 // 但i32是Copy的,所以在后面可以继续使用x } // 这里,x先移出了作用域,然后是s,...
true
54d7af8400a727944df57356fbac9cf03ca948cc
Rust
glium/glium
/src/draw_parameters/stencil.rs
UTF-8
14,266
2.71875
3
[ "Apache-2.0" ]
permissive
use crate::gl; use crate::context; use crate::ToGlEnum; /// Describes the parameters that must be used for the stencil operations when drawing. #[derive(Copy, Clone, Debug)] pub struct Stencil { /// A comparison against the existing value in the stencil buffer. /// /// Only relevant for faces that are cloc...
true
ceee4bed39b568e9a28e91950ad7a22cf2519568
Rust
Troinnn/snake
/src/models/field.rs
UTF-8
593
2.671875
3
[]
no_license
use opengl_graphics::GlGraphics; use piston::input::*; pub struct Field { pub scalar: i32, } impl Field { pub fn new(scalar: i32) -> Field { Field { scalar } } pub fn render(&self, gl: &mut GlGraphics, arg: &RenderArgs) { let dark_blue: [f32; 4] = [0.0, 0.0, 0.3, 1...
true
f2912a187cd68654ff439aa16d7ecc176e9ff2a8
Rust
whymidnight/redis_orderbook
/redis/src/types/redis_sorted_set.rs
UTF-8
4,262
3.046875
3
[ "MIT" ]
permissive
use redis::Commands; pub use redis::FromRedisValue; use redis::ToRedisArgs; pub use redis::RedisResult; pub fn zadd<T: ToRedisArgs, U: ToRedisArgs>(conn: &mut redis::Connection, key: &str, value: T, score: U) -> redis::RedisResult<()> { conn.zadd(key, value, score) } pub fn zrange<T: ToRedisArgs, RV: FromRedisVal...
true
56f71bd7be96aab079f65bcf76aacc52a88c21bf
Rust
aquova/AdventofCode
/src/aoc2020/day2/mod.rs
UTF-8
1,533
3.140625
3
[]
no_license
use crate::utils::*; pub fn day2p1() -> Option<u32> { let mut total = 0; let input = read_lines("src/day2/input.txt"); for line in input.iter() { let mut occurances = 0; let words: Vec<&str> = line.split(" ").collect(); let range: Vec<&str> = words[0].split("-").collect(); l...
true
c5e3d96d2b0ed730ab7a528fc5d2608d2b570254
Rust
diesel-rs/diesel
/diesel_cli/tests/migration_run.rs
UTF-8
17,266
2.8125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::support::{database, project}; use diesel::dsl::sql; use diesel::sql_types::Bool; use diesel::{select, RunQueryDsl}; use std::path::Path; #[test] fn migration_run_runs_pending_migrations() { let p = project("migration_run").folder("migrations").build(); let db = database(&p.database_url()); // M...
true
53a04d63623f212b9f0728c711cded9d34b5d814
Rust
andyolsen/rust
/rustdev/demos/03_ownership_and_borrowing/simple_ownership/src/main.rs
UTF-8
1,437
4.03125
4
[]
no_license
fn main() { demo_scope(); demo_string_type(); demo_copying_vs_moving(); demo_clone(); } fn demo_scope() { let x = 42; if x != 0 { let s = "Andy"; println!("s {}", s); } // Nope: // println!("s {}", s); } fn demo_string_type() { let mut s = String::from("super"); s.push_str(" swans"); println...
true
d3c30e46bd7192e97b1d671b9e2790a05a0dc7b4
Rust
forny/advent-of-code-2020
/rust/day22/src/main.rs
UTF-8
2,847
3.25
3
[]
no_license
//! Solutions to 2020: Advent of Code day 22 //! By Peter Fornwall use std::collections::HashSet; use std::collections::VecDeque; use std::fs; fn get_score(cards: &[VecDeque<usize>], p1_wins: bool) -> usize { let winner_cards = if p1_wins { &cards[0] } else { &cards[1] }; let mut score = 0; for i in 0..wi...
true
1ce32d28f26adf64cf516f3c2dce67ca9b3028f7
Rust
damononliu/rust
/main.rs
UTF-8
3,914
3.796875
4
[]
no_license
/* 1、程序通过 `cargo run` 编译并启动后,Mac 通过 `lsof -i:8866` 可以看到 `TCP localhost:8866 (LISTEN)` 表示监听启动成功。 2、客户端通过 telnet 进行测试,测试命令 : `telnet localhost 8866` 输入字符返回响应字符测试通过。 3、为了可以连接多个客户端,需要使用 thread 类库对多线程进行处理。 4、输入`bye`程序退出,并提示 `see you soon.` */ // 引用类库 io、net 用来完成TCP监听读取 use std::{io::{Read, Write}, net::{TcpListener, TcpStre...
true
dca2bbc1111def0d844fdac7b92f5617cb7f77c7
Rust
Dunklas/aoc-2020
/src/main.rs
UTF-8
1,465
2.703125
3
[]
no_license
use std::{env, fs}; mod grid; mod solutions; fn main() { let args: Vec<String> = env::args().collect(); let day = args[1].as_str(); let input = read_puzzle_input(day); match args[1].as_str() { "1" => solutions::day1::run(input), "2" => solutions::day2::run(input), "3" => soluti...
true
9ed7375a24c9f07a070eb84c2f251d8ab4c11007
Rust
bugadani/embedded-menu
/src/collection.rs
UTF-8
7,419
2.796875
3
[ "MIT" ]
permissive
use core::marker::PhantomData; use embedded_graphics::{ pixelcolor::Rgb888, prelude::{DrawTarget, PixelColor, Point, Size}, primitives::Rectangle, }; use embedded_layout::{object_chain::ChainElement, prelude::*, view_group::ViewGroup}; use crate::{ interaction::InputAdapterSource, selection_indica...
true
05e129d405e70a68e85e85c47d8b74dc3fe5e70a
Rust
linianhui/div
/src/class/field.rs
UTF-8
1,439
2.71875
3
[ "MIT" ]
permissive
// https://docs.oracle.com/javase/specs/jvms/se12/html/jvms-4.html#jvms-4.5 /* field_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2 attributes_count; attribute_info attributes[attributes_count]; } */ use crate::class::Attribute; use c...
true
95d447d53a667ef465b73969ce2c3b3815998442
Rust
devcexx/fancontrol
/src/device/drivers/nct6775.rs
UTF-8
1,784
2.609375
3
[]
no_license
use std::io::Result; use super::hwmon::HwmonDevice; use crate::{ device::{Device, DeviceBuilder, PwmMode}, types::TempCelsius, }; use udev::Device as UdevDevice; const NCT6775_PWM_MODE_FULL: &str = "0"; const NCT6775_PWM_MODE_MANUAL: &str = "1"; const NCT6775_PWM_MODE_AUTO: &str = "5"; pub struct Builder; i...
true
1de58d4ea03e85b781e62bd0cde1cf85925ea403
Rust
RonaldDijks/chime
/src/evaluator.rs
UTF-8
4,203
3.46875
3
[]
no_license
use std::collections::HashMap; use crate::syntax_tree::{BinOpKind, CompilationUnit, Expression, Statement}; #[derive(Debug, Copy, Clone)] pub enum EvaluatorValue { Unit, Float(f64), Bool(bool), } impl EvaluatorValue { pub fn to_string(&self) -> String { match self { EvaluatorValue...
true
f4920abd5ae3872c6c12453ad719d83db24baabd
Rust
danslocombe/music-visualizer
/src/audio/mod.rs
UTF-8
8,300
2.96875
3
[]
no_license
use std::collections::{LinkedList, HashMap}; use std::io::Read; use std::time::{Duration, SystemTime}; use std::thread::sleep; use std::sync::mpsc::Sender; use std::path::Path; use std::fs::File; use common::{AudioType, AudioPacket, AudioUpdate}; use hound::{Sample, WavReader}; pub mod mp3; pub mod wav; pub trait Son...
true
b37d2c4106ea112a7bcda97e3da3d79cfe451799
Rust
Luro02/shorthand
/src/visibility.rs
UTF-8
2,223
3.4375
3
[ "Apache-2.0", "MIT" ]
permissive
//! This module is for the visibility attribute use syn::parse::{Parse, ParseStream}; use syn::{LitStr, Visibility}; use crate::error::Error; use crate::parser::parse_shorthand; mod kw { syn::custom_keyword!(visibility); syn::custom_keyword!(inherit); } #[derive(Debug, Clone, PartialEq)] pub enum FieldVisib...
true
0d0c02dd3fd9cfb841bada972fce9eccb2d37037
Rust
Ainevsia/Leetcode-Rust
/26. Remove Duplicates from Sorted Array/src/main.rs
UTF-8
570
3.4375
3
[ "BSD-2-Clause" ]
permissive
fn main() { Solution::remove_duplicates(&mut vec![1,1,2]); } struct Solution {} impl Solution { pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { let mut vec = vec![]; for i in nums.iter() { if Some(i) != vec.last() { vec.push(*i); } } ...
true
41cfc1e05501422ef35c6ccf5941cb2f1e0c5c8c
Rust
fridge-dev/frj-game-ngn
/src/backend-framework/src/wire_api/type_converters.rs
UTF-8
7,265
2.78125
3
[]
no_license
/// Wrappers of the `oneof` message type in protobuf. mod oneof_wrappers { use crate::wire_api::proto_frj_ngn::proto_love_letter_data_out::ProtoLvLeOut; use crate::wire_api::proto_frj_ngn::proto_pre_game_message::{ ProtoGameStartMsg, ProtoJoinGameAck, ProtoPlayerJoinMsg, }; use crate::wire_api::...
true
f82e951ab4537e677074bd54afd1c59b3efb3179
Rust
chux0519/proc-macro-workshop
/test-runner/src/message.rs
UTF-8
4,454
2.734375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use termcolor::Color::*; use super::{Expected, Test}; use crate::banner; use crate::error::Error; use crate::normalize; use crate::term; use std::path::Path; use std::process::Output; pub(crate) fn prepare_fail(err: Error) { if err.already_printed() { return; } term::bold_color(Red); print!(...
true
07483fb0adb9ed9d691f50ce61b86a69b7afd676
Rust
raystyle/tau-engine
/src/json.rs
UTF-8
1,552
2.96875
3
[ "MIT" ]
permissive
// Trait implementations that allow the solver to be gneric over serde_json's `Value`. use std::borrow::Cow; use serde_json::map::Map; pub use serde_json::{Number, Value as Json}; use crate::document::Document; use crate::value::{AsValue, Object, Value}; impl AsValue for Json { #[inline] fn as_value(&self) ...
true
7988ab2a8c0def13715f05a6c490d9a808cb7617
Rust
zhangf911/swiboe
/src/client/event_loop.rs
UTF-8
4,440
2.609375
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Swiboe development team. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE.txt // in the project root for license information. use ::client::rpc_loop; use ::ipc; use mio::tcp::TcpStream; use mio::unix::UnixStream; use mio; use std::io; use std::thread; const CLIE...
true
208241d99da18a7933d741cf7eb5355210150270
Rust
CGQAQ/postcss-rs
/crates/tokenizer/tests/tokenizer_test.rs
UTF-8
10,560
3.25
3
[ "MIT" ]
permissive
use tokenizer::input::Input; use tokenizer::*; fn tokenize(css: &str, ignore_errors: bool) -> Vec<Token> { let input = Input::new(css, None); let processor = Tokenizer::new(input.css, ignore_errors); let mut tokens = vec![]; while !processor.end_of_file() { tokens.push(processor.next_token(false)) } tok...
true
c24995813e8332d999b89ca75453954259c52a79
Rust
burtonageo/glium
/src/index/local.rs
UTF-8
8,371
2.953125
3
[ "Apache-2.0" ]
permissive
use backend::Facade; use index::IndicesSource; use index::ToIndicesSource; use index::IntoIndexBuffer; use index::IndexBuffer; use index::Index; use index::PrimitiveType; /// A list of points stored in RAM. #[derive(Clone)] pub struct PointsList<T>(pub Vec<T>); impl<T> IntoIndexBuffer for PointsList<T> where T: Inde...
true
d24d1c4e282ae839bfea73fa3b494095c70dfe90
Rust
adamnemecek/quantum
/src/asset/texture.rs
UTF-8
1,447
3.21875
3
[]
no_license
use nalgebra::Vector2; use rendy::texture::pixel::Rgba8Srgb; #[derive(Debug)] pub struct TextureAsset { data: Vec<Rgba8Srgb>, dimensions: Vector2<u32>, } impl TextureAsset { pub fn from_file(path: &str) -> Result<Self, &'static str> { if let Ok(image) = image::open(path) { let img = i...
true
bc75e49ef6e32bedc852fb568137e14e23e80349
Rust
NilsHasNoGithub/just_another_card_game
/card_game_server/src/main.rs
UTF-8
4,009
2.890625
3
[]
no_license
extern crate clap; extern crate serde; extern crate shared_lib; extern crate think_thank_rust; use clap::{App, Arg, ArgMatches}; use shared_lib::data_structures::{Card, GameState, GameStatePlayer, MenuState}; use shared_lib::socket_message_passing::{read_message, write_message}; use std::error::Error; use std::io::Rea...
true
8c0ad116cee0b0321abac773bf0ca2b2af193048
Rust
clehner/serde_jcs
/src/entry.rs
UTF-8
364
2.59375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::BTreeMap; #[derive(Clone, Debug)] pub struct Entry { pub object: BTreeMap<Vec<u8>, Vec<u8>>, pub next_key: Vec<u8>, pub next_val: Vec<u8>, pub complete: bool, } impl Entry { pub fn new() -> Self { Self { object: BTreeMap::new(), next_key: Vec::new(), next_val: Vec...
true
04599ef8edc1702b2fe28e43c154d494f17c9c9b
Rust
barreiro/euler
/src/main/rust/euler/algorithm/filter.rs
UTF-8
4,316
3.15625
3
[ "MIT" ]
permissive
// COPYRIGHT (C) 2022 barreiro. All Rights Reserved. // Rust solvers for Project Euler problems use algorithm::cast::Cast; use algorithm::digits::{DEFAULT_RADIX, Digits, digits_iter, nth_digit}; use algorithm::factor::sum_of_factors; use algorithm::prime::miller_rabin; use algorithm::root::int_log_10; /// verifies if...
true
b20513cd2e9498c4b7cec7dd4001ab93d957013e
Rust
xycaleth/advent-of-code-2020
/rust/8.rs
UTF-8
3,300
3.390625
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::path::Path; #[derive(Clone)] enum Op { NoOp(i32), Acc(i32), Jmp(i32), } struct OpInfo { op: Op, visited: bool, } struct Program { ops: Vec<OpInfo>, accumulator: i32, program_counter: i32, } impl OpInfo { ...
true
4a4b1876a17db4c0c55859d6ec761d1b77ff32c3
Rust
authereum/zksync
/core/server/src/utils/token_db_cache.rs
UTF-8
1,932
2.9375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{ collections::HashMap, sync::{Arc, RwLock}, }; use models::node::{Token, TokenId, TokenLike}; use storage::ConnectionPool; #[derive(Debug, Clone)] pub struct TokenDBCache { db_pool: ConnectionPool, // TODO: handle stale entries. (edge case when we rename token after adding it) tokens: Ar...
true
dc5e06f61177a6d66b6d1e290f2d7f96deb1af9e
Rust
urawa72/rust-procon-snippets
/src/binary_search.rs
UTF-8
1,404
3.65625
4
[]
no_license
use cargo_snippet::snippet; use std::cmp::Ordering; #[snippet(include = "BinarySearch")] pub trait BinarySearch<T> { fn lower_bound(&self, x: &T) -> usize; fn upper_bound(&self, x: &T) -> usize; } #[snippet("BinarySearch")] impl<T: Ord> BinarySearch<T> for [T] { fn lower_bound(&self, x: &T) -> usize { ...
true
a62dcfcb81e632fd9037b50f48cf88c41d81a1aa
Rust
equalsraf/pwx
/build.rs
UTF-8
1,264
2.65625
3
[ "ISC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate gcc; use std::fs::File; use std::io::Write; /// Convert docopt segment to markdown /// /// - replace pwx with `pwx` for formatting /// - append <br> tag at EOL /// - remove whitespace from line start /// - replace <> with entities &lt; &gt; fn ronn_synopsis() -> String { let d = String::from(include_...
true
6765540387de56f5a3a64f5129482adf773f662f
Rust
RemiliaForever/light2d-rust
/src/main.rs
UTF-8
1,281
2.859375
3
[]
no_license
extern crate image; extern crate rayon; extern crate rand; use image::ImageBuffer; use image::Rgb; use rayon::prelude::*; mod chapter1; mod chapter2; const WIDTH: u32 = 1024; const HEIGHT: u32 = 1024; use std::time::SystemTime; use std::error::Error; fn gen(fun: fn(f32, f32, Vec<u32>) -> Rgb<u8>, path: &str, param:...
true
f6f52cdcca8ce07859d02662ebfa3448b1184aa8
Rust
AntyMew/livesplit-core
/capi/src/time_span.rs
UTF-8
884
3.171875
3
[ "MIT", "Apache-2.0" ]
permissive
//! A Time Span represents a certain span of time. use livesplit_core::TimeSpan; use super::{acc, alloc, own_drop}; /// type pub type NullableTimeSpan = TimeSpan; /// type pub type OwnedTimeSpan = *mut TimeSpan; /// Clones the Time Span. #[no_mangle] pub unsafe extern "C" fn TimeSpan_clone(this: *const TimeSpan) -> ...
true
686a8d13f7753be3b5d719d3302b1103af02c02a
Rust
TheDan64/daily-quote
/frontend/groupme/src/main.rs
UTF-8
1,269
3.0625
3
[ "Apache-2.0" ]
permissive
pub mod bot; use std::env; use std::io::{stdin, Read}; use anyhow::{Context, Result}; use dotenv::dotenv; use structopt::StructOpt; use crate::bot::Bot; #[derive(Debug, StructOpt)] enum BotCmd { /// Either provide a string or else read from stdin #[structopt(name = "send")] Send { message: Optio...
true
17740e97f05829a4544bfd75e7e65c34876c7824
Rust
yeahnoob/rust-prometheus
/src/counter.rs
UTF-8
11,987
2.84375
3
[ "Apache-2.0" ]
permissive
// Copyright 2014 The Prometheus Authors // Copyright 2016 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless ...
true
70ecfd70740d6831501f59a6bb2b234360da4c42
Rust
bevyengine/bevy
/crates/bevy_ecs/src/entity/mod.rs
UTF-8
34,157
3.71875
4
[ "MIT", "Apache-2.0", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! Entity handling types. //! //! An **entity** exclusively owns zero or more [component] instances, all of different types, and can dynamically acquire or lose them over its lifetime. //! //! **empty entity**: Entity with zero components. //! **pending entity**: Entity reserved, but not flushed yet (see [`Entities::f...
true
fe1ddeae76e21a7eebd28e29acac0cb66437f681
Rust
LukasOtter/chipmunk
/application/apps/indexer/processor/src/text_source.rs
UTF-8
6,287
2.734375
3
[ "Apache-2.0" ]
permissive
use crate::grabber::{ identify_byte_range, ByteRange, GrabError, GrabMetadata, GrabbedContent, GrabbedElement, LineRange, MetadataSource, Slot, }; use buf_redux::{policy::MinBuffered, BufReader as ReduxReader}; use indexer_base::{progress::ComputationResult, utils}; use std::{ fs, io::{BufRead, Read, Se...
true
e8f57a69644d127493c246be52e744efa5a3066d
Rust
pokefreak627/MUSICM8
/src/main.rs
UTF-8
6,127
2.671875
3
[]
no_license
use futures::StreamExt; use songbird::{ input::{Input, Restartable}, tracks::TrackHandle, Songbird, }; use std::{collections::HashMap, error::Error, sync::Arc}; use tokio::{spawn, sync::RwLock}; use twilight_gateway::{Cluster, Event, Intents}; use twilight_http::Client as HttpClient; use twilight_model::{ch...
true
129cc819ddb98701da2f2bbf7e2f2cdb26b75a9c
Rust
dakom/awsm-web
/crate/src/tick/raf.rs
UTF-8
1,514
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use std::rc::Rc; use std::cell::RefCell; pub struct Raf { state: Rc<RefCell<Option<RafState>>>, } struct RafState { id: i32, closure: Closure<dyn FnMut(f64)>, } impl Raf { pub fn new<F>(mut callback: F) -> Self where F: FnMut(f64) + 'static { ...
true
4a883ce540693221c28bed80ab532a428217c6d2
Rust
wade-wu/mayastor
/mayastor/src/host/blk_device.rs
UTF-8
10,311
2.921875
3
[ "Apache-2.0" ]
permissive
//! //! This module implements the list_block_devices() gRPC method //! for listing available disk devices on the current host. //! //! The relevant information is obtained via udev. //! The method works by iterating through udev records and selecting block //! (ie. SUBSYSTEM=block) devices that represent either disks ...
true
8cd655311415b6bf4690fe5b95f81c26698a08de
Rust
tuffing/adventofcode2015
/aoc2015/src/day06.rs
UTF-8
3,445
3.5625
4
[]
no_license
pub mod solution { use regex::Regex; pub fn run() -> (usize, usize) { let input = match crate::loadinput::file::load_input_multi_line("../../inputs/day06/input.txt") { Ok(val) => val, Err(_) => { println!("NO FILE"); return (0,0); }, }; part_1_2_naive(input) } /// /// This is an extrem...
true
de8dfc6007171e46d24dd800762a6610b9a6c7a2
Rust
romatthe/another-world-suite
/engine/src/lib/poly.rs
UTF-8
6,423
2.734375
3
[ "MIT" ]
permissive
use std::cmp; use crate::utils::{read_u16}; use crate::defines::{FRAME_BUFFER_WIDTH, FRAME_BUFFER_HEIGHT}; const MAX_NUM_VERTICES: usize = 50; pub fn draw_poly_to_buffer(poly: &mut Poly, poly_buffer: &[u8], offset: u16, x: i16, y: i16, zoom: i16, color_idx: u8, output_pages: &mut [Vec<u8>; 4], backbuffer_page_idx: us...
true
65760cdeb7aee1b33be0abd3aa5c7636db763465
Rust
Noah2610/deathframe
/deathframe_core/src/components/component_helpers/action_queue/tests.rs
UTF-8
1,150
3.171875
3
[ "MIT" ]
permissive
use super::ActionQueue; type MockAction = u8; #[derive(Default)] struct MockQueue { actions: Vec<MockAction>, } impl ActionQueue for MockQueue { type Action = MockAction; fn mut_actions(&mut self) -> &mut Vec<Self::Action> { &mut self.actions } } #[test] fn can_add_actions() { let mut qu...
true
dbca1309e3fe4695364d4fcd9617c8cdedbb69dd
Rust
daveallie/grapple
/src/auth_helper.rs
UTF-8
7,594
2.875
3
[ "MIT" ]
permissive
use base64; use md5; use reqwest::header::Headers; use reqwest::Client; use std::collections::HashMap; use std::sync::Mutex; use url::Url; use uuid::Uuid; lazy_static! { static ref NONCES: Mutex<HashMap<String, usize>> = Mutex::new(HashMap::new()); } pub struct AuthenticationRequest { method: Option<String>, ...
true
a433b8108261ab02ef99b7bd5d80b0cc238396e6
Rust
robmoore-i/AdaptiveCompression
/Code/proj/src/column.rs
UTF-8
2,319
3.078125
3
[]
no_license
use cracker_index::AVLCrackerIndex; use std::slice::Iter; pub trait Column { type Item; fn empty() -> Self; fn rearrange(&mut self, indices: Iter<usize>); fn at(self, idx: usize) -> Self::Item; fn append(&mut self, values: &mut Vec<Self::Item>); } #[derive(Clone)] pub struct IntCol { // Origi...
true