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
40a635ec24cda8817a1812a893dc55132efe0eb6
Rust
sourcedennis/rust-vox-parser
/src/data/mod.rs
UTF-8
549
2.671875
3
[ "BSD-3-Clause" ]
permissive
//! Data structures representing `.vox` file contents. //! //! Two representations are included: [`spec`] and [`custom`]. The former //! faithfully represents chunks as demanded by the specification. However, //! working with a vector of raw chunks may be difficult. `custom` contains //! convenient data structures tha...
true
abc610ee07d200aa0469b8fa3f34babc3d004bdc
Rust
lukecollier/advent-of-code-2020
/three/src/main.rs
UTF-8
1,565
3.125
3
[]
no_license
#[cfg(windows)] const LINE_ENDING: &'static str = "\r\n"; #[cfg(not(windows))] const LINE_ENDING: &'static str = "\n"; fn count_tree_hits(map: &Vec<Vec<u8>>, right: &usize, down: &usize) -> u8 { let (result, _) = map .into_iter() .step_by(*down) .fold((0, 0), |(acc, pos), line| { ...
true
bdd616a887e54ff9921f7618c4c9e31c8e65629e
Rust
grubern/vulkano
/vulkano/src/descriptor/descriptor.rs
UTF-8
6,110
2.828125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be co...
true
edd22d8f86d8de9c88cb39187e65520ff9e4dada
Rust
akhramov/knast
/netzwerk/src/interface.rs
UTF-8
12,823
2.796875
3
[ "MIT" ]
permissive
mod operations; use std::{ffi::CStr, mem}; use anyhow::Error; use common_lib::AsSignedBytes; use libc::{AF_INET, SOCK_DGRAM}; use crate::{bindings::ifreq, common_bindings::Socket}; use operations::{ bridge_addm, bridge_delm, check_interface_existence, create_interface, destroy_interface, jail_interface, rena...
true
b40b89fb8a8d879af07634dca382c18c89269a7a
Rust
nicochatzi/soultrain
/src/download/downloadable.rs
UTF-8
1,506
2.578125
3
[]
no_license
use crate::download::{*, progress::*}; use std::{fs, io, path::PathBuf}; use exitfailure::ExitFailure; use reqwest::{ blocking::{Client, Response}, header, Url, }; pub type DownloadResult<T> = Result<T, ExitFailure>; pub struct DownloadInfo { pub url: Url, pub file: PathBuf, pub size: u64, } pu...
true
b674244415b632438df0ace32e33805e19b05448
Rust
Allen-B1/vsim2
/src/methods/fptp.rs
UTF-8
1,884
2.625
3
[]
no_license
use crate::core::*; use std::collections::{HashMap,HashSet}; use std::iter::Iterator; #[derive(Clone)] pub struct FPTP; impl ElectoralMethod for FPTP { fn as_any(&self) -> &dyn std::any::Any { self } fn district_size(&self) -> u32 { 1 } fn run(&self, stage: &ElectionStage, r: &El...
true
6306e7d769e0aa10953c42481c19b9019dec050e
Rust
booleancoercion/advent-of-code-2020
/src/day10.rs
UTF-8
1,375
3.078125
3
[]
no_license
use std::cmp::min; use aoc_runner_derive::*; #[aoc_generator(day10)] fn generate(input: &str) -> Vec<u32> { let mut vec: Vec<u32> = input .lines() .map(|x| u32::from_str_radix(x, 10).unwrap()) .collect(); vec.sort_unstable(); vec.insert(0, 0); vec.reverse(); vec.insert(0, ...
true
9d606ad6407c1537b76a750815b09d5412213842
Rust
junsikh/faiss_rust_tutorial_code
/src/main.rs
UTF-8
2,149
2.90625
3
[]
no_license
use faiss::{Index, index_factory, MetricType}; use rand::{SeedableRng, rngs::StdRng}; use rand::distributions::{Distribution, Uniform}; fn main() { println!("faiss tutorial test"); // Reference in Python: // https://github.com/facebookresearch/faiss/blob/master/tutorial/python/1-Flat.py // prepare da...
true
729828e9f65689ebc64542d3c265fca33f43e354
Rust
pbrook/aoc
/2020/17/src/main.rs
UTF-8
5,494
3.25
3
[]
no_license
use std::fs::File; use std::io::{self, BufRead}; type Slice = Vec<Vec<bool>>; type Cube = Vec<Slice>; type HCube = Vec<Cube>; fn parse_line(s: String) -> Vec<bool>{ return s.chars().map(|c| c == '#').collect(); } fn parse(filename: &str) -> Slice { let file = File::open(filename).unwrap(); let lines = io...
true
86e5714c79b48d87d9009c07ddf680b51abeb23b
Rust
natefduncan/proximity-rs
/src/utils.rs
UTF-8
2,409
3.171875
3
[]
no_license
use super::density::{Point}; use csv; use std::io; use std::fs; use rust_decimal::prelude::*; pub fn get_x_y(points: Vec<Point>, x_cat: &str) -> (Vec<Point>, Vec<Point>) { //Split into x and y points let mut x_points : Vec<Point> = Vec::new(); let mut y_points : Vec<Point> = Vec::new(); for point in &...
true
a1f00b20d62d6ca2eee24cb99319897380d13208
Rust
afflom/coreos-diskimage-rehydrator
/src/riverdelta.rs
UTF-8
7,736
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
//! A river delta is a fork of a stream. Yes, I am clever at naming. //! This module manages a "parsed" version of a stream that is //! organized around how we manage deltas. use anyhow::{anyhow, Context, Result}; use camino::Utf8Path; use coreos_stream_metadata::{Artifact, Platform, Stream}; use fn_error_context::co...
true
60031218c48766369e6317c2e1ded8a476850842
Rust
lePerdu/twisted
/src/cube/cube3/coord/util.rs
UTF-8
705
2.9375
3
[ "MIT" ]
permissive
//! Helper functions for computing 3x3x3 cube coordinates. //! //! This are mostly concerned with distinguishing between E-slice edges and U-D slice edges. use crate::cube::edge::EdgePos; use crate::util::IntoEnumIterator; pub fn in_e_slice(pos: EdgePos) -> bool { // E edges are last, DL is the last D edge po...
true
781d837cc0f6bfb2509f0f02df3392c711ccb7fa
Rust
Koura/blockchain-example
/src/api.rs
UTF-8
3,545
2.75
3
[ "MIT" ]
permissive
use crate::blockchain::{Block, Blockchain, Transaction}; use actix_web::{web, HttpRequest, HttpResponse}; use serde::{Deserialize, Serialize}; use std::sync::Mutex; #[derive(Serialize, Deserialize)] pub struct MessageResponse { message: String, } #[derive(Serialize, Deserialize)] pub struct TransactionRequest { ...
true
709695f80a25a10414bd93ab95abce36de8556df
Rust
jmpargana/exercism
/rust/collatz-conjecture/src/lib.rs
UTF-8
289
2.90625
3
[]
no_license
pub fn collatz(n: u64) -> Option<u64> { collatz_rec(n, 0) } fn collatz_rec(n: u64, i: u64) -> Option<u64> { match (n, n % 2) { (0, _) => None, (1, _) => Some(i), (x, 0) => collatz_rec(x / 2, i + 1), (x, _) => collatz_rec(x * 3 + 1, i + 1), } }
true
5cca0a15b4f0f9eb57d99f9fd5aba7e3e0bf1c3c
Rust
udoprog/OxidizeBot
/crates/oxidize-chat/src/module.rs
UTF-8
1,560
2.640625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use async_injector::Injector; use async_trait::async_trait; use common::BoxFuture; use std::collections::HashMap; use std::sync::Arc; use crate::command; use crate::idle; use crate::sender; use crate::stream_info; use anyhow::Result; #[derive(Default)] pub struct Handlers { handlers: HashMap<String, Arc<dyn comm...
true
1048705c40ea126478ae0bc990514235ee5af6d2
Rust
GREsau/okapi
/rocket-okapi/src/error.rs
UTF-8
776
2.578125
3
[ "MIT" ]
permissive
use okapi::merge::MergeError; use std::error::Error; use std::fmt; /// Type alias for `Result<T, OpenApiError>`. pub type Result<T> = std::result::Result<T, OpenApiError>; /// The error type returned by `rocket_okapi` when something fails. #[derive(Debug, Clone)] pub struct OpenApiError { msg: String, } impl Ope...
true
a64d966e5de61ba1fbb72356860bca6ce9a6e17f
Rust
davisp/fortuna-rs
/src/js_engine.rs
UTF-8
5,968
2.578125
3
[ "Apache-2.0" ]
permissive
use rusty_v8 as v8; use std::convert::TryFrom; // This is created in build.rs and is all the required js code added into // a byte array include!(concat!(env!("OUT_DIR"), "/js_startup_code.rs")); // TODO: Handle errors properly pub struct FortunaIsolate { isolate: v8::OwnedIsolate, global_context: v8::Global...
true
fbcb455ca1ee3ec652c49ad0a2a51af06c7e652d
Rust
withoutboats/access-queue
/src/lib.rs
UTF-8
6,152
3.3125
3
[]
no_license
//! [`AccessQueue`], which allows only a certain number of simultaneous accesses to a guarded item. //! //! This can be useful for implementing backpressure: when accessing the item through the //! [`Access`] future, tasks will wait to access the item until others have completed, limiting the //! number of accesses tha...
true
9f584faa8ee1e9b384c15409180052893d73d7e1
Rust
celo-org/celo-threshold-bls-rs
/crates/dkg-core/src/primitives/joint_feldman.rs
UTF-8
15,223
2.734375
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
//! Implements the Distributed Key Generation protocol from //! [Pedersen](https://link.springer.com/content/pdf/10.1007%2F3-540-48910-X_21.pdf). //! The protocol runs at minimum in two phases and at most in three phases. use super::common::*; use crate::primitives::{ group::Group, phases::{Phase0, Phase1, Phas...
true
68b274f0fd6f18e46e25c0c07f3e1a2ec935e4b3
Rust
bytesonus/juno
/src/models/module.rs
UTF-8
3,229
2.734375
3
[]
no_license
use crate::utils::logger; use std::collections::HashMap; use async_std::sync::RwLock; use futures::channel::mpsc::UnboundedSender; use futures_util::sink::SinkExt; use semver::{Version, VersionReq}; lazy_static! { pub(crate) static ref JUNO_MODULE: RwLock<Option<Module>> = RwLock::new(None); } #[derive(Clone)] //...
true
634af95f144d839586fc098411fac089a43ef049
Rust
reitermarkus/compiler-construction
/mc_symbol_table/src/add_to_scope.rs
UTF-8
7,850
2.609375
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use mc_parser::ast::*; use crate::*; use super::extend_errors; use crate::semantic_checks::*; pub trait AddToScope<'a> { fn add_to_scope(&self, scope: &Rc<RefCell<Scope<'a>>>) -> Result<(), Vec<SemanticError<'a>>>; } impl<'a> AddToScope<'a> for IfStatement<'a> { fn add_...
true
737f0e4194df2a778ffecea3120362424003375d
Rust
seb-odessa/users-server
/src/lib/db.rs
UTF-8
2,532
2.984375
3
[]
no_license
use rusqlite::{Connection, Error}; use messages::{UserDesc, Response, Status, CMD}; const USERS_DB: &'static str = "users.db"; pub fn process(cmd : CMD, user : &UserDesc) -> Response { match connect() { Ok(conn) => { match cmd { CMD::CREATE => user_create(&conn, &user), ...
true
91873835831553f8ff8bf55b463b8e2c09247728
Rust
plaflamme/philos
/src/qemu.rs
UTF-8
298
2.890625
3
[]
no_license
use x86_64::instructions::port::Port; #[derive(Debug, Clone, Copy, Eq, PartialEq)] #[repr(u32)] pub enum ExitCode { Success = 0x10, Failure = 0x11, } pub fn exit(code: ExitCode) { let mut isa_exit_port = Port::new(0xf4); unsafe { isa_exit_port.write(code as u32); } }
true
943bcc31ea03ce16017dc5e37a229c3063c57d0e
Rust
jakubadamw/parallel-for-macro
/src/lib.rs
UTF-8
2,119
2.890625
3
[]
no_license
#![feature(proc_macro_diagnostic)] extern crate proc_macro; use proc_macro::TokenStream; #[macro_use] extern crate quote; use quote::ToTokens; struct Visit; impl Visit { fn emit_diagnostic(&self, span: proc_macro::Span, name: &'static str) { proc_macro::Diagnostic::spanned( span, proc_macro:...
true
bc382c514fe1715936b753603f86d1f9f7ac1286
Rust
TianTianForever/Rust-Tutorial
/closures.rs
UTF-8
441
2.90625
3
[]
no_license
fn main() { // Increment via closures and functions. fn functions (i: i32) -> i32 { i + 1 } let closure_annotated = |i: i32| -> i32 { i + 1 }; let closure_inferred = |i | { i + 1 }; let i = 1; // Call the cloures and functions. println!("cloure_annotated: {}", closur...
true
538fd0def81a54ccc09a5b0fd0deaec392af4ac6
Rust
asnelling/psst
/psst-gui/src/controller/on_command.rs
UTF-8
852
2.625
3
[ "MIT" ]
permissive
use druid::{widget::Controller, Data, Env, Event, EventCtx, Selector, Widget}; pub struct OnCommand<U, F> { selector: Selector<U>, handler: F, } impl<U, F> OnCommand<U, F> { pub fn new<T>(selector: Selector<U>, handler: F) -> Self where F: Fn(&mut EventCtx, &U, &mut T), { Self { se...
true
98df3cae752ed2622cb1e8e9a65c5e5cb2f1caaf
Rust
astral-sh/ruff
/crates/ruff_dev/src/print_ast.rs
UTF-8
564
2.640625
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
//! Print the AST for a given Python file. #![allow(clippy::print_stdout, clippy::print_stderr)] use std::fs; use std::path::PathBuf; use anyhow::Result; use ruff_python_parser::parse_suite; #[derive(clap::Args)] pub(crate) struct Args { /// Python file for which to generate the AST. #[arg(required = true)] ...
true
8d2292dd294481e0ea751abe30c3d77c003d1414
Rust
pitcer/brucket
/brucket-parser/src/lexer/mod.rs
UTF-8
7,238
3.328125
3
[ "MIT" ]
permissive
use crate::token::{ Boolean, Keyword, Modifier, Number, Operator, Parenthesis, PrimitiveType, Token, }; use derive_more::Constructor; use std::borrow::Cow; use std::iter::Peekable; use std::option::Option::Some; use std::str::Chars; #[cfg(test)] mod tests; #[derive(Default, Constructor)] pub struct Lexer; trait ...
true
461cef4070473bc61e48d6d23fc566ec67a53830
Rust
Klaven/later
/cli/src/main.rs
UTF-8
445
2.953125
3
[ "MIT" ]
permissive
use quicli::prelude::*; use structopt::StructOpt; #[derive(Debug,StructOpt)] struct Cli { #[structopt(long = "message", short = "m")] message: Option<String>, #[structopt(long = "list", short = "l")] list: Option<String>, } fn main() { let args = Cli::from_args(); match args.message { ...
true
0e7dd958985cea8c8d148a921c912f30d9fa42f5
Rust
akiselev/declarative-dataflow
/src/plan/antijoin.rs
UTF-8
1,972
2.671875
3
[ "MIT" ]
permissive
//! Antijoin expression plan. use timely::dataflow::Scope; use timely::dataflow::scopes::child::Iterative; use differential_dataflow::operators::Join; use differential_dataflow::operators::Threshold; use plan::Implementable; use Relation; use {QueryMap, RelationMap, SimpleRelation, Var}; /// A plan stage anti-joini...
true
861f182a835057e6836dcdbb753d1404a794f1cf
Rust
rustycity/kay
/src/id.rs
UTF-8
7,673
2.921875
3
[ "MIT" ]
permissive
use crate::type_registry::ShortTypeId; use crate::actor_system::World; use crate::actor::ActorOrActorTrait; /// Represents an `ActorSystem` in a networking topology #[cfg_attr( feature = "serde-serialization", derive(Serialize, Deserialize) )] #[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash, Debug)]...
true
28806ca46a7b4aaeb1553639f5afa701f0998062
Rust
KieronJ/rnes
/src/nes/rom.rs
UTF-8
2,404
3.234375
3
[ "MIT" ]
permissive
use std::io::Read; pub const ROM_CHR_BANK_SIZE: usize = 8192; pub const ROM_HEADER_SIZE: usize = 16; pub const ROM_PRG_BANK_SIZE: usize = 16384; pub enum MirrorMode { Horizontal, Vertical, FourScreen, OneScreen } #[derive(Clone)] pub struct INesHeader { magic: [u8; 4], prg: u8, ...
true
7fc8f50db2616f0a8ae62e0ce5ed1c3408d102f6
Rust
Farzy/fant-asm
/helper/src/unicode.rs
UTF-8
355
3.21875
3
[ "Apache-2.0" ]
permissive
pub fn main() { let chars: Vec<u8> = vec![0xA0, 0x15, 65, 0xFE, 0x18, 65, 0xC3, 0xAA, 0x7C, 98]; let s = String::from_utf8_lossy(&chars); println!("{:X?} = '{}'", chars, s); let s = "é œ ê ô € ñ"; println!( "'{}' ({}) = {:X?} ({})", s, s.chars().count(), s.as_bytes(...
true
f8d76e08aac7daac62f900167bccca68a447dff6
Rust
smashedtoatoms/aoc2020
/src/day-2/src/main.rs
UTF-8
3,952
3.46875
3
[ "MIT" ]
permissive
use anyhow::{anyhow, Result}; use input_file::Input; /// Contains password and rules for password validity. struct PasswordMetadata { pass: String, min: usize, max: usize, valid_char: char, } /// AOC2 fn main() -> Result<()> { let passwords = Input::from_args()? .strings("\n") .map...
true
b024259a182a0d28c510cb56e331c208e818e7a4
Rust
iCodeIN/ggez-game-of-life
/src/cell.rs
UTF-8
1,663
3.734375
4
[]
no_license
#[derive(Debug, Copy, Clone)] pub struct Point2D { pub x: i64, pub y: i64, } #[derive(Clone)] pub struct Cell { pub alive: bool, } impl Cell { pub fn new(alive: bool) -> Cell { Cell { alive } } pub fn next_state(&self, neighbours: i8) -> bool { if self.alive && (neighbours < ...
true
712db13a9cd98763c91b96e63b433bd307a38dac
Rust
kdy1/stackoverflow-56728860
/src/main.rs
UTF-8
735
2.53125
3
[]
no_license
extern crate chashmap; extern crate lazy_static; use chashmap::{CHashMap, ReadGuard}; use lazy_static::lazy_static; use std::collections::HashMap; struct Data {} #[derive(Default)] struct Merged { types: HashMap<String, Data>, } fn merge(ls: &[String]) -> ReadGuard<'static, Vec<String>, Merged> { lazy_static...
true
5921f9f78a220fdb7c0135cdff8ad67b1485f850
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/agc029/src/bin/b.rs
UTF-8
1,037
2.828125
3
[]
no_license
use std::{cmp::Reverse, collections::BTreeMap}; use proconio::input; fn main() { input! { n: usize, mut a: [usize; n], }; a.sort_by_key(|&a_i| Reverse(a_i)); let mut map = BTreeMap::new(); for a_i in a.iter().copied() { *map.entry(a_i).or_insert(0) += 1; } let mut...
true
68ee1e8537da0a213628577b36701d22ae971d57
Rust
joshradin/modular_lang
/lexer/src/lexing.rs
UTF-8
18,817
3.1875
3
[]
no_license
use crate::tokenization::TokenType::EOF; use crate::tokenization::{ Compound, Control, Declare, Literal, Loop, ObjectOrientation, Operator, Security, Structural, Token, TokenType, }; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::Chars; pub struct Lexer { filename: String, str...
true
75df13c3daa0567079d7a1ecbe30c81356aa4a16
Rust
jonhoo/hanabot
/src/hanabi/components.rs
UTF-8
6,252
3.265625
3
[ "MIT", "Apache-2.0" ]
permissive
use rand::seq::SliceRandom; use rand::thread_rng; use std::collections::LinkedList; /// An error that occurred while giving a clue. pub(crate) enum ClueError { NoSuchPlayer, NoMatchingCards, NotEnoughClues, GameOver, } /// An error that occurred while giving playing a card. pub(crate) enum PlayError {...
true
fb57258db58b2e5468d66bfda7752b7df204d684
Rust
semtexzv/rmaps
/rmaps/src/map/style/expr/util.rs
UTF-8
2,539
2.828125
3
[]
no_license
use ::prelude::*; use super::{ Type, eval::*, val::*, }; pub fn expect_type(t: Type, v: Value) -> ExprResult { return if v.get_type() == t { Ok(v) } else { Err(EvalError::InvalidType { expected: t, got: v.get_type(), }) }; } pub fn expect_num(v:...
true
93fb2bf78b5608c8b24d16d54eeff79378a83b4e
Rust
LorenzoTanga-bot/safe-devicelocatorui
/backend/src/map/tiles.rs
UTF-8
2,003
2.828125
3
[]
no_license
use std::collections::HashSet; use reqwest::Client; use reqwest::header::{HeaderMap, USER_AGENT}; use std::path::Path; use bytes::Bytes; use crate::map::TileCoords; use futures::{stream, StreamExt}; use walkdir::WalkDir; use crate::data::get_data_dir; const PARALLEL_REQUESTS: usize = 128; pub async fn get_map_tiles(c...
true
4518900be369b165af4c16c8bb405ac15119acf9
Rust
dvc94ch/cargo-trace
/bpf-helpers/src/map.rs
UTF-8
8,422
2.90625
3
[ "MIT", "Apache-2.0" ]
permissive
//! eBPF maps. //! //! Maps are a generic data structure for storage of different types of data. //! They allow sharing of data between eBPF kernel programs, and also between //! kernel and user-space code. use core::ffi::c_void; use core::marker::PhantomData; use core::mem; use cty::c_int; #[repr(transparent)] pub st...
true
bc72f7e4a8cad9e8be4261ba53eead548f98a7e3
Rust
hgzimmerman/Perceptron
/src/lib.rs
UTF-8
10,161
3.359375
3
[]
no_license
#![feature(test)] extern crate test; use std::convert::{From,Into}; use std::boxed::Box; #[derive(Debug)] pub struct Perceptron { learning_rate: f64, // constant value to alter the weights by per training iteration epochs: usize, // Number of times to iterate while training. weights: Vec<f64>, // The othe...
true
58b1905fa321d569c46b8e69ca0f15f44369898b
Rust
BenDoan/playground
/rust/cminus-compiler/src/util.rs
UTF-8
364
2.859375
3
[ "MIT" ]
permissive
pub fn get_pos(program: &String, byte: usize) -> (u32, u32) { let mut line_count = 1; let mut col_count = 1; for (i, c) in program.chars().enumerate() { if c == '\n' { line_count += 1; col_count = 1 } if i == byte { break; } col_cou...
true
97da9c268ab8bab11eae681cb0bcedecd9fd0fd9
Rust
Phytolizer/monky
/monky/src/parser.rs
UTF-8
28,943
2.90625
3
[]
no_license
use std::collections::HashMap; use std::mem::swap; use maplit::hashmap; use once_cell::sync::Lazy; use crate::ast::BlockStatement; use crate::ast::Boolean; use crate::ast::CallExpression; use crate::ast::Expression; use crate::ast::ExpressionStatement; use crate::ast::FunctionLiteral; use crate::ast::Identifier; use ...
true
5a2c710edba09e99caf5c25f76cbec1bc7ae33cf
Rust
dyaso/klein-ported-to-rust
/klein/src/inner_product.rs
UTF-8
8,141
3
3
[ "MIT" ]
permissive
#![cfg(target_arch = "x86_64")] use std::arch::x86_64::*; use crate::detail::inner_product::{ dot00, dot03, dot11, dot33, dot_pil_flip, dot_pil_noflip, dot_pl_flip, dot_pl_noflip, dot_ptl, }; use crate::{IdealLine, Line, Plane, Point}; use std::ops::BitOr; /// \defgroup dot Symmetric Inner Product /// /// The s...
true
05dc1e300b89a2bba7398701e19260b50e04a208
Rust
gitter-badger/ProDBG
/src/prodbg/main/src/windows.rs
UTF-8
8,512
2.65625
3
[ "MIT" ]
permissive
extern crate minifb; extern crate bgfx_rs; extern crate viewdock; use bgfx_rs::Bgfx; use libc::{c_void, c_int}; use minifb::{Scale, WindowOptions, MouseMode, MouseButton}; use core::view_plugins::{ViewHandle, ViewPlugins, ViewInstance}; use core::session::{Sessions, Session, SessionHandle}; use self::viewdock::{Worksp...
true
cbade97e011935a9d0ffe0c2a005472e4bdb6d01
Rust
deadshot465/demo_game
/src/game/shared/traits/mappable.rs
UTF-8
880
2.859375
3
[ "BSD-3-Clause" ]
permissive
use ash::vk::*; /// メモリ的にマップすることができるリソース(イメージ、バッファなど)<br /> /// Resources that can be mapped to an address in memory, such as images and buffers. pub trait Mappable { //fn allocate_memory(&mut self, instance: &ash::Instance, physical_device: PhysicalDevice, memory_properties: MemoryPropertyFlags) -> DeviceMemory; ...
true
aa19e7abbfe6971f5d98aafda908e9abefc963c1
Rust
oussama/webaudio-rs
/example/src/simple.rs
UTF-8
931
2.75
3
[ "Apache-2.0" ]
permissive
use utils::*; use webaudio::*; use application::*; use futures::*; pub fn main() { let size = (800, 600); let config = AppConfig::new("Test", size); let mut app = App::new(config); let file_data = include_bytes!("../assets/nocturne.ogx"); let ctx = AudioContext::new(); let mut future = ctx.d...
true
10ef392768d4b0501eebc7a08412601356255d47
Rust
akovaski/AdventOfCode
/2020/25/aoc2020_25a.rs
UTF-8
946
2.984375
3
[]
no_license
use std::fs::File; use std::io::BufReader; use std::io::prelude::*; use std::io::Result; fn main() -> Result<()> { let lines: Vec<String> = BufReader::new(File::open("input.txt")?).lines().map(|l| l.unwrap()).collect(); assert!(lines.len() == 2); let keys: Vec<i64> = lines.into_iter().map(|l| l.parse().unw...
true
d87627c9be2bd742e2b9e5bb24b238f3e1ce0763
Rust
Leorii/VoidLeo
/src/handler/mod.rs
UTF-8
2,708
2.671875
3
[]
no_license
use crate::{command, util::Logger, AppConfig}; use serenity::{ model::{channel::Message, gateway::Ready, guild::Member, id::GuildId}, prelude::{Context, EventHandler}, }; use std::sync::Arc; pub struct Handler { config: Arc<AppConfig>, } impl Handler { pub fn new(config: Arc<AppConfig>) -> Self { ...
true
dc2b03016778d37353637fb54b0fa2ea00bbd137
Rust
gitgolly/Ellie-Language
/parser/src/syntax/types/operator_type.rs
UTF-8
3,246
2.734375
3
[ "MIT" ]
permissive
//This is will catch operator with unknown behaviour use crate::syntax::types; use crate::syntax::variable; use serde::Serialize; use crate::syntax::types::arithmetic_type::ArithmeticOperators; use crate::syntax::types::comparison_type::ComparisonOperators; use crate::syntax::types::logical_type::LogicalOpearators; ...
true
770960c1368a31e29964c7d6237680aea6231ed5
Rust
hamaluik/scribbler-server
/src/routes/auth_tests/mod.rs
UTF-8
4,298
2.828125
3
[ "Apache-2.0" ]
permissive
use rocket::http::{ContentType, Method, Status, Header}; use rocket::local::Client; use serde_json; use communication::SignInResponse; mod sign_up; #[test] fn get_params() { // setup the server and client let rocket = ::setup_server().expect("server setup"); let client = Client::new(rocket).unwrap(); ...
true
7109aa196262fc1e8ba694bed49b543df8557466
Rust
jix/varisat
/varisat-formula/src/test.rs
UTF-8
4,933
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use proptest::{prelude::*, *}; use rand::{distributions::Bernoulli, seq::SliceRandom}; use crate::{cnf::CnfFormula, lit::Lit}; /// Generate small hard unsat instances. /// /// Implementation of http://www.cs.qub.ac.uk/~i.spence/sgen/ but with random partitions pub fn sgen_unsat_formula( blocks: impl Strategy<Val...
true
c258cef6a7d90532c208d2bf49d7d302411ee2ac
Rust
mrkaspa/servinator
/src/structs.rs
UTF-8
884
2.53125
3
[]
no_license
#[derive(Debug)] pub struct Data { pub dir: String, pub config: Option<String>, } #[derive(Deserialize, Debug)] pub struct Config { pub url: String, pub token: String, pub organization_id: i32, pub service_type_id: i32, pub operators: i32, } #[derive(Debug, Deserialize, Serialize, Clone)] ...
true
29f8e12c9b44d24e2fa8f71bd530ee0d97f526e3
Rust
derrickbaldwin/euler-project
/rust/problem_20/src/main.rs
UTF-8
169
2.53125
3
[]
no_license
extern crate problem_20; use problem_20::factorial; use problem_20::sum_of_factorial_digits; fn main() { println!("{}", sum_of_factorial_digits(factorial(100))); }
true
9cb365a6170a54e93963c0754d3b471c7287a784
Rust
ivfranco/notes
/Dragon_Book/chapter_11/loop_nest/src/affine.rs
UTF-8
3,390
3.265625
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
use std::cmp; use std::ops::{Mul, Neg, Sub}; pub type Coeff = i32; pub type Var = char; #[derive(Clone)] pub struct Affine { coeffs: Vec<Coeff>, } #[allow(clippy::len_without_is_empty)] impl Affine { pub fn new(coeffs: Vec<Coeff>) -> Self { if coeffs.is_empty() { Affine::new_zero() ...
true
4fc2431dbcd0026464f5c7bc63fd6df3a7604a1e
Rust
diogobaeder/eulerust
/p001/src/main.rs
UTF-8
449
3.640625
4
[ "BSD-2-Clause" ]
permissive
fn sum(n: u32) -> u32 { let mut res = 0; for i in 0..n { if i % 3 == 0 || i % 5 == 0 { res += i } } res } fn main() { println!("{}", sum(1000)); } #[cfg(test)] mod tests { use super::*; #[test] fn sums_0() { assert_eq!(sum(0), 0); } #[tes...
true
d10879f90ced58cd51bf11d7cb853bfd33b8619c
Rust
SpaceManiac/discord-rs
/src/builders.rs
UTF-8
11,087
2.953125
3
[ "MIT" ]
permissive
//! Builder types used for patches and other complex data structures. //! //! These types do not usually need to be imported, but the methods available //! on them are very relevant to where they are used. use serde_json::Value; use chrono::offset::FixedOffset; use chrono::DateTime; use model::*; use Object; macro_...
true
4d5e3379c59650ca4ff40f58f36c6c5d5c390186
Rust
charypar/monobuild
/rs/src/git.rs
UTF-8
5,613
3.375
3
[ "MIT" ]
permissive
use thiserror::Error; pub type Commit = String; pub type Command = Vec<String>; pub enum Mode { Feature(String), // base branch, e.g. 'main' Main(String), // base commit, e.g. 'HEAD^1' } #[derive(PartialEq, Error, Debug)] pub enum GitError { #[error("Cannot find merge base with branch {0}: {1}")] ...
true
1c121251e131200ab5102b62ff5fbe50af7aa78d
Rust
eduidl/gauss-newton-rs
/tests/nalgebra_ver.rs
UTF-8
1,735
2.78125
3
[ "MIT" ]
permissive
use approx::relative_eq; use nalgebra as na; use gauss_newton_rs::nalgebra_ver::{GaussNewton, Problem}; pub struct SampleProblem { x: na::DVector<f32>, s: na::DVector<f32>, v: na::DVector<f32>, } impl SampleProblem { fn new() -> Self { let x = na::DVector::from_vec(vec![1.5, 1.5]); le...
true
6edef0b7f1478bdd7eedc1af1684f5dc81f14389
Rust
PetarV-/advent-of-rust
/src/bin/aor-09.rs
UTF-8
3,763
3.1875
3
[ "MIT" ]
permissive
use std::cmp::min; use std::cmp::max; use std::collections::HashMap; use std::io::prelude::*; use std::fs::File; use std::path::Path; use std::cell::RefCell; const INFTY: u32 = 1 << 30; struct Node { adj: Vec<(String, u32)> } struct Graph { names: HashMap<String, usize>, nodes: Vec<RefCell<Node>> } impl...
true
1be958c9ce8d5b7209c95bb74e177155bcf36858
Rust
pt2121/scion
/src/core/components/shapes/line.rs
UTF-8
2,339
2.96875
3
[ "MIT" ]
permissive
use std::ops::Range; use wgpu::{util::BufferInitDescriptor, PrimitiveTopology}; use crate::{ core::components::{material::Material, maths::{coordinates::Coordinates, Pivot}}, rendering::{gl_representations::TexturedGlVertex, Renderable2D}, }; const INDICES: &[u16] = &[0, 1]; /// Renderable 2D Line. pub stru...
true
3a705a105ee2b07715ed65b245397188b3dae9bb
Rust
tiburin/on
/src/v1/parse.rs
UTF-8
2,845
3.25
3
[ "MIT" ]
permissive
use super::{Method, MiError, Req}; pub struct Parser<'a, 'b> { pub req: &'a mut Req<'b>, } impl<'a, 'b> Parser<'a, 'b> { pub fn new(req: &'a mut Req<'b>) -> Self { Self { req } } pub fn parse(&mut self, buffer: &[u8]) -> Result<&Req, MiError> { let data = std::str::from_utf8(&buffer[..]).unwrap(); ...
true
988ac28ef4b29c99fba1e0e292a0d241540ca04b
Rust
PacktPublishing/Rust-Standard-Library-Cookbook
/Chapter01/src/bin/builder.rs
UTF-8
3,468
3.921875
4
[ "MIT" ]
permissive
fn main() { // We can easily create different configurations let normal_burger = BurgerBuilder::new().build(); let cheese_burger = BurgerBuilder::new().cheese(true).salad(false).build(); let veggie_bigmac = BurgerBuilder::new().vegetarian(true).patty_count(2).build(); if let Ok(normal_burger) = nor...
true
2dcf438ae12d80e5dfce8ac90859c9f49f765ccd
Rust
spectraldani/pocketbattle
/src/stats.rs
UTF-8
2,517
3.3125
3
[ "MIT" ]
permissive
use std::ops::Index; #[derive(Debug)] pub enum Stat { Hp, Attack, Defense, Speed, SpecialAttack, SpecialDefense } #[derive(Debug,PartialEq,Copy,Clone)] pub struct Stats { pub hp: u16, pub atk: u16, pub def: u16, pub spd: u16, pub sat: u16, pub sdf: u16, } #[derive(Debu...
true
1adfe5d8d41a69d08ea901cf662965935f056fed
Rust
TomSpencerLondon/ruruby
/src/vm/iseq.rs
UTF-8
12,528
2.53125
3
[ "MIT" ]
permissive
use super::vm_inst::*; use crate::*; #[derive(Clone, Default)] pub struct ISeq(Vec<u8>); use std::ops::{Index, IndexMut, Range}; use std::{convert::TryInto, fmt}; impl Index<usize> for ISeq { type Output = u8; fn index(&self, index: usize) -> &Self::Output { &self.0[index] } } impl IndexMut<usize...
true
a1b41728f6fb1913378345ed293f2bd22094e24b
Rust
cmsd2/rogue1
/src/qs_game.rs
UTF-8
3,162
2.671875
3
[ "MIT", "LicenseRef-scancode-ubuntu-font-1.0" ]
permissive
use std::rc::Rc; use quicksilver::prelude::*; use quicksilver::graphics::View; use specs::prelude::*; use crate::ai::Ai; use crate::scene::Scene; use crate::data::Data; use crate::game::ecs; use crate::game::system::{GameActionType, GameActor, GameSystem}; use crate::qs_ui::Tileset; use crate::data::GameText; type Sys...
true
88ee1c6e711137bd3313324c83a2163b8a63c399
Rust
maxtnuk/gluesql
/test-suite/src/function/rand.rs
UTF-8
1,815
2.546875
3
[ "Apache-2.0" ]
permissive
use { crate::*, gluesql_core::{ executor::EvaluateError, prelude::{Payload, Value::*}, translate::TranslateError, }, }; test_case!(rand, async move { let test_cases = [ ( "CREATE TABLE SingleItem (qty INTEGER DEFAULT ROUND(RAND()*100))", Ok(Payloa...
true
329461069f98bbb6609b64f82eafd01e4110b9ba
Rust
shino16/cp_rust
/src/math/primes.rs
UTF-8
512
2.90625
3
[ "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::ds::idx::*; pub fn prime_table(upto: u32) -> IdxInt<bool> { let mut pr = IdxInt(vec![true; upto as usize + 1]); pr[0] = false; pr[1] = false; for i in 2..=upto { if pr[i] { for j in (i + i..=upto).step_by(i as usize) { pr[j] = false; } ...
true
f6902019a0eefe0d9279ce99dd3541939c8bab5b
Rust
wampiedriessen/adventofcode
/archive/2017/src/day24.rs
UTF-8
2,893
2.90625
3
[]
no_license
#[cfg(test)] mod tests { use super::*; #[test] fn part1_sample_test() { let sample_input = "0/2 2/2 2/3 3/4 3/5 0/1 10/1 9/10"; assert_eq!(31, run1(parse_input(sample_input))); } #[test] fn part2_sample_test() { let sample_input = "0/2 2/2 2/3 3/4 3/5 0/1 10/1 9/10"; assert_eq!(19, run2(par...
true
13aefc3d94fe5d6f7deaf61db652e50b6721a6d7
Rust
nmbr7/Rusty-Fuzzer
/src/mutengine.rs
UTF-8
5,909
3
3
[ "BSD-3-Clause" ]
permissive
use crate::config::{ProgConfig, SeedConfig, Stat}; use crate::fuzzstat::FuzzerStatus; use crate::helpertools::{random, random_range}; use std::collections::VecDeque; use std::format; use std::io::Read; #[derive(Debug, Clone)] pub struct Mutation { pub parent: usize, pub mutant: MutType, } #[derive(Debug, Clone...
true
f04595fd16ab6647bdb0f0970e17f0a226b32335
Rust
aegroto/splaysort-rs
/src/splay.rs
UTF-8
782
2.671875
3
[]
no_license
pub mod top_down; pub mod visit; pub mod sort; #[cfg(test)] mod tests; use std::fmt::Debug; pub trait BinaryTree<K: Ord + 'static> { fn binary_insert(&mut self, key: K); fn binary_search(&self, key: K) -> Option<&K>; fn binary_delete(&mut self, key: K); } pub trait SplayTree<K: Ord + 'static> { fn ...
true
1b0f16ee41519aca608083e8e4d369702ababad1
Rust
njsh4261/benchmarksgame
/bencher/programs/fibonacci/fibonacci.rs
UTF-8
594
3.6875
4
[ "BSD-3-Clause", "MIT", "BSD-2-Clause" ]
permissive
use std::env::args; fn fib(num: i32) -> i32 { if num == 0 { return 0; } else if num == 1 { return 1; } else { return fib(num-1) + fib(num-2); } } fn main() { let args: Vec<String> = args().collect(); let args_1 = args.get(1); let num: i32 = match args_1 { ...
true
3ac6294fbf42f23157babbd2d2806bc315b29366
Rust
eastrd/bevy_text_mesh
/src/text_mesh.rs
UTF-8
4,199
2.671875
3
[ "MIT" ]
permissive
use bevy::prelude::*; use glyph_brush_layout::{HorizontalAlign, VerticalAlign}; use crate::{mesh_system::TextMeshState, TextMeshFont}; pub use ttf2mesh::Quality; #[derive(Default, Bundle, Debug)] pub struct TextMeshBundle { /// Text mesh configuration pub text_mesh: TextMesh, /// Standard bevy [`Transfor...
true
ca67ed44036aec298ba8a76d78b3fc87c98271c0
Rust
jice-nospam/uni-snd
/src/snd.rs
UTF-8
5,772
3.109375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std; use std::sync::mpsc::{channel, Receiver, Sender}; use super::{SoundError, SoundGenerator}; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use cpal::{self, Device, Sample, SampleFormat, Stream}; use uni_app::App; /// This is the sound API that allows you to send events to your generator. pub struct ...
true
065c5bbf3b426c727c22e9053aefa6d35c7b7de6
Rust
lemonrock/rust-c
/test/src/lib.rs
UTF-8
2,881
3.078125
3
[]
no_license
#![cfg_attr(not(test), allow(dead_code))] #![allow(improper_ctypes)] #[macro_use] extern crate c; #[cfg(test)] use std::ffi::CString; c! { // Bring in rust-types! #include "rust_types.h" } c! { fn basic_math_impl(a: i32 as "rs::i32", b: i32 as "rs::i32") -> i32 as "rs::i32" { int32_t c = a * 10;...
true
132f75cff54e8bd1d0a16a4dfc7edf6f5f8f0d1e
Rust
anlumo/cef
/src/load_handler.rs
UTF-8
55,078
2.859375
3
[]
no_license
use cef_sys::{ cef_browser_t, cef_errorcode_t, cef_frame_t, cef_load_handler_t, cef_string_t, cef_transition_type_t, }; use std::{convert::TryFrom}; use bitflags::bitflags; use crate::{ browser::Browser, frame::Frame, refcounted::{RefCountedPtr, Wrapper}, string::CefString, }; bitflags!{ //...
true
b883909708260ee8bee3aab40356eb6fe06b35d6
Rust
projectfluent/fluent-rs
/fluent-syntax/benches/parser.rs
UTF-8
5,535
2.875
3
[ "Apache-2.0", "MIT" ]
permissive
use criterion::criterion_group; use criterion::criterion_main; use criterion::Criterion; use std::collections::HashMap; use std::fs; use std::io; use fluent_syntax::parser::parse_runtime; fn read_file(path: &str) -> Result<String, io::Error> { fs::read_to_string(path) } #[cfg(feature = "all-benchmarks")] fn get_...
true
1c72e3ca24f23c775a718aeaf0e5edf0c8e50c29
Rust
marc47marc47/leetcode-cn
/1207unique-occurr/unique-occur/src/main.rs
UTF-8
586
3.3125
3
[]
no_license
fn main() { println!("Hello, world!"); } pub struct Solution; impl Solution { pub fn unique_occurrences(mut arr: Vec<i32>) -> bool { let mut counter = vec![0;2001]; for v in arr{ counter[v as usize + 1000] = counter[v as usize+1000] +1; } let mut set = std::collec...
true
99ff9244efdd49fb91b8ec507489ed21c870456d
Rust
wasmerio/cranelift
/cranelift-codegen/src/legalizer/heap.rs
UTF-8
6,001
2.984375
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Legalization of heaps. //! //! This module exports the `expand_heap_addr` function which transforms a `heap_addr` //! instruction into code that depends on the kind of heap referenced. use crate::cursor::{Cursor, FuncCursor}; use crate::flowgraph::ControlFlowGraph; use crate::ir::condcodes::IntCC; use crate::ir::{...
true
cbde62d367a568d5ff4590bbc37ef0c69ff0eae6
Rust
EthanTheMaster/calculator_parser
/src/calculator/lexer.rs
UTF-8
5,161
3.6875
4
[]
no_license
use crate::parser::Normalize; #[derive(Debug, Clone, Hash, Eq, PartialEq)] pub enum Token { Space, LParen, RParen, Add, Mult, Sub, Div, Exp, // String parameter holds the lexeme Int(String), Float(String), Id(String), Comma } impl Normalize for Token { // Allows...
true
d9c3ad333bacd88bbb7824dbeb2dfc889ec8bcca
Rust
tensorbase/tensorbase
/crates/arrow/src/array/iterator.rs
UTF-8
16,869
2.96875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
3155b2102956ef1f11ef9804d87ba16660fe47ef
Rust
JavaHello/erm-tools-rs
/src/core/env.rs
UTF-8
4,236
2.53125
3
[]
no_license
use serde::Deserialize; use std::collections::HashMap; use std::fs; use std::io::prelude::*; use std::sync::{Arc, RwLock}; const COV_TYPE_FILE_PREFIX: &str = "cov_type_"; const COV_TYPE_FILE_EXT: &str = ".json"; const COV_TYPE_PATH: &str = "./conf/"; lazy_static! { static ref COV_SQL_TYPE: Arc<RwLock<HashMap<Str...
true
87ce4c00e6973a9360e137697ba1a5f13a4fa528
Rust
matszczygiel/opengl-tests
/rust/src/camera.rs
UTF-8
1,821
3.046875
3
[]
no_license
extern crate cgmath; use cgmath::*; pub struct Camera { pub perspective: PerspectiveFov<f32>, pub position: Point3<f32>, pub horizontal_angle: Rad<f32>, pub vertical_angle: Rad<f32>, } impl Camera { pub fn new_default(width: f32, height: f32) -> Self { Self::new_default_aspect(width / hei...
true
8c3b324d397bd58357b96afa7267d35a615e1403
Rust
LinAGKar/advent-of-code-2015-rust
/day4a/src/main.rs
UTF-8
1,541
2.859375
3
[ "MIT" ]
permissive
use std::io::Read; use std::sync::{Arc, Mutex}; fn main() { let mut input = Vec::new(); std::io::stdin().read_to_end(&mut input).unwrap(); let orig_len = input.len(); let answer_mutex = Arc::new(Mutex::new(None)); let cores = num_cpus::get(); let threads: Vec<_> = (0..cores).map(|i| { ...
true
c40d4a5f2c68595dd4cdcb92787e688d3e56ca15
Rust
steabert/project-euler
/src/problem_009.rs
UTF-8
688
3.578125
4
[]
no_license
// Special Pythagorean triplet // A Pythagorean triplet is a set of three natural numbers, // a < b < c, for which, a2 + b2 = c2 // For example, 32 + 42 = 9 + 16 = 25 = 52. // There exists exactly one Pythagorean triplet for which a + b + c = 1000. // Find the product abc. fn main() { let mut answer: u32 = 0; ...
true
51484d2c7b5c68a10940edb79995e1034c7659ac
Rust
pointlander/geiger
/client/src/main.rs
UTF-8
2,392
2.78125
3
[]
no_license
use std::error::Error; use std::env; use std::fmt; use std::io::prelude::*; use std::net::TcpStream; use std::time::{SystemTime, UNIX_EPOCH}; use crossbeam_channel::{bounded, Receiver, select}; use ctrlc; use rppal::gpio::{Gpio, Trigger}; use rppal::i2c::I2c; use rppal::system::DeviceInfo; #[derive(Debug)] struct MyE...
true
3b7bd8e5fb324e48946164f406f3244ea84af6f2
Rust
HeroicKatora/static-alloc
/without-alloc/src/rc.rs
UTF-8
22,562
3.453125
3
[ "MIT", "Zlib", "Apache-2.0" ]
permissive
//! Reference counter value. //! //! See [`Rc`] for more information. //! //! [`Rc`]: ./struct.Rc.html use core::{borrow, cmp, fmt, hash, mem, ops, ptr}; use core::alloc::Layout; use core::cell::Cell; use crate::uninit::{Uninit, UninitView}; /// A single-threaded reference-counting pointer. 'Rc' stands for 'Reference...
true
661931d87625b561a6e6589dd029f606d6a953f8
Rust
blofroth/border
/border-tch-agent/src/model/base.rs
UTF-8
3,327
3.3125
3
[ "Apache-2.0", "MIT" ]
permissive
//! Definition of interfaces of neural networks. use std::path::Path; use tch::{nn, nn::VarStore, Tensor}; use anyhow::Result; /// Base interface. pub trait ModelBase { /// Trains the network given a loss. fn backward_step(&mut self, loss: &Tensor); /// Returns `var_store`. fn get_var_store(&mut self)...
true
6b915685be2bca760152f917cac175444d67bd16
Rust
alexander-akhmetov/mos
/src/drivers/pit.rs
UTF-8
941
2.875
3
[]
no_license
use crate::cpuio; const DEFAULT_FREQ: u32 = 1_193_180; const PIT_CONTROL_PORT: u16 = 0x43; const PIT_DATA_PORT: u16 = 0x40; pub fn init(frequency: u32) { /// sets PIT frequency to "frequency" unsafe { // by default PIT generates a signal with 1.193182 MHz frequency // it's configurable, if we ...
true
bd6793a807e4c885ee532c0323cfd6164eff588d
Rust
mishaszu/RUST-INTRO
/src/ex2/ownership_03/src/slices.rs
UTF-8
1,044
3.703125
4
[]
no_license
fn frist_word(s: &String) -> usize { let bytes = s.as_bytes(); for (i, &item) in bytes.iter().enumerate() { if item == b' ' { return i; } } s.len() } fn frist_word2(s: &String) -> &str { let bytes = s.as_bytes(); for (i, &item) in bytes.iter().enumerate() { ...
true
4c301215b90e6dd8827baa55ae9a79b8c93fc91b
Rust
sohardforaname/SimpleRustLuaJIT
/src/main.rs
UTF-8
884
2.546875
3
[]
no_license
mod ast; mod util; mod codegen; use ast::lexer::Lexer; use crate::ast::parser::Parser; use std::fs::File; use std::io::{Read, BufReader, BufRead}; fn main() { /* let mut parser: Parser = Parser::new(&"local a = 123 + 6 b = 1" .to_string(), &"D:\\test.txt".to_string()); parser.check_grammar(); ...
true
67f66dac826b132bab590a90aa72c481b7593268
Rust
Graviton-One/api_server
/gton_api_server/src/gton_stats/added_values.rs
UTF-8
2,617
2.640625
3
[]
no_license
use diesel::prelude::*; use actix_web_dev::error::{ Result, }; use bigdecimal::BigDecimal; use serde::{ Serialize, Deserialize, }; use diesel::sql_types::{ Integer, Varchar, Numeric, }; #[derive(Serialize,Deserialize,Debug,Clone)] pub struct UsersValuesSerde { pub sender_address: String, ...
true
50c58838e2cb7479fbe608263b226894cf33c4ef
Rust
dfalbel/extendr
/extendr-api/examples/R/classes/src/lib.rs
UTF-8
465
2.625
3
[ "MIT" ]
permissive
use extendr_api::prelude::*; #[derive(Debug)] struct Person { pub name: String, } #[extendr] impl Person { fn new() -> Self { Self { name: "".to_string() } } fn set_name(&mut self, name: &str) { self.name = name.to_string(); } fn name(&self) -> &str { self.name.as_st...
true
afe94704d7d37c62db92c41b253e16bb2ea1f9be
Rust
DarkOtter/indexed-bitvec-rs
/benches/operations.rs
UTF-8
3,255
2.65625
3
[ "Apache-2.0" ]
permissive
/* Copyright 2018 DarkOtter Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writi...
true
60ac5b1f3ccaf9ce73111f1cc9a01e2ca6db9640
Rust
steve3p0/cs510r
/hw2/pythagorean-triplet/src/lib.rs
UTF-8
738
3.390625
3
[]
no_license
// Inspired by: // https://www.w3resource.com/euler-project/euler-problem9.php pub fn find() -> Option<u32> { for a in 1..1000 { for b in 2..1000 { // I had to use i32 for c because subtracting // a and b would overflow (- negative) let c:i32 = 1000 - a - b; ...
true
9744df8304042ac3a4261442a621a45b6fe820e5
Rust
calebmer/accelerate
/src/main.rs
UTF-8
7,526
2.65625
3
[ "MIT" ]
permissive
#![allow(unused_parens)] extern crate clap; extern crate colored; extern crate regex; #[macro_use] mod error; mod motions; mod accelerator; mod driver; use std::env; use std::path::Path; use std::process; use std::io; use std::io::prelude::*; use clap::{App, Arg, SubCommand}; use clap::AppSettings::*; use colored::C...
true
fa1db9e1add2091d7a27da808163edb6d012cad7
Rust
pedantic79/Exercism
/rust/high-scores/src/lib.rs
UTF-8
1,057
3.421875
3
[]
no_license
#[derive(Debug)] pub struct HighScores<'a>(&'a [u32]); impl<'a> HighScores<'a> { pub fn new(scores: &'a [u32]) -> Self { Self(scores) } pub fn scores(&self) -> &[u32] { self.0 } pub fn latest(&self) -> Option<u32> { self.0.iter().last().copied() } pub fn personal_...
true
c9369388b748a576f03865b70fec54230ec30125
Rust
Marthog/stm-datastructures
/src/bounded_queue.rs
UTF-8
6,101
3.640625
4
[]
no_license
use stm::*; use std::any::Any; use super::Queue; /// `Queue` is a threadsafe FIFO queue, that uses software transactional memory. /// /// It is similar to synchronous channels, but undoes operations in case of aborted txactions. /// /// /// # Example /// /// ``` /// extern crate stm; /// extern crate stm_datastructure...
true