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
126c25dee4bbaafe8a712cba4052be66acd0c276
Rust
adamaho/tallii-backend
/src/services/users/models.rs
UTF-8
1,864
2.75
3
[]
no_license
use serde::{Deserialize, Serialize}; /// Database representation of a User #[derive(sqlx::FromRow, Serialize)] pub struct User { pub user_id: i32, pub emoji: String, pub bg_color: String, pub email: String, pub password: String, pub invite_code: String, pub username: String, pub bio: Op...
true
d9f7e6af7e325007e681730501ef5d98b92c7a75
Rust
AHobbyistDev/Cryptopals-Rust
/src/util/ioutil.rs
UTF-8
1,091
3.28125
3
[]
no_license
use std::io; use std::io::{ BufReader, Error, ErrorKind }; use std::io::prelude::*; use std::fs::File; use util::base64::Base64Parseable; use util::hex::HexParseable; /// Attempts to read a file and interpret its contents as Base64-encoded. pub fn read_base64(file: &str) -> io::Result<Vec<u8>> { let f = try!(File...
true
6d26196f7fdfc84345cd0dbce6522361b315635d
Rust
valkum/advent_of_code_2020
/src/day19.rs
UTF-8
4,805
3.046875
3
[]
no_license
use std::{cell::RefCell, char, str::FromStr}; use anyhow::Result; use aoc_runner_derive::aoc; use aoc_runner_derive::aoc_generator; use itertools::Itertools; use nom::{IResult, Parser, bits::complete::take, branch::alt, branch::permutation, character::complete::{alpha0, anychar, char, digit1, one_of, space0, space1}, ...
true
351e3bb9eb09bed971d6c649f16b32099f3c2b74
Rust
ChorusOne/tendermint-rs
/light-client/src/components/verifier.rs
UTF-8
3,221
2.71875
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
use crate::predicates as preds; use crate::{ errors::ErrorExt, light_client::Options, operations::{ CommitValidator, Hasher, ProdCommitValidator, ProdHasher, ProdVotingPowerCalculator, VotingPowerCalculator, }, types::LightBlock, }; use preds::{errors::VerificationError, ProdPredicat...
true
c93d529405d350294273c24601af2b789f362adb
Rust
jroweboy/marauder
/visualizer/mesh.rs
UTF-8
2,024
2.578125
3
[ "MIT" ]
permissive
// See LICENSE file for copyright and license details. use core::types::MInt; use visualizer::gl_helpers::{Vbo, Vao, Triangles}; use visualizer::types::{Color3, VertexCoord, TextureCoord}; use visualizer::shader::Shader; use visualizer::texture::Texture; pub struct Mesh { vertex_coords_vbo: Vbo, color_vbo: Op...
true
796b60541d0896e9fbe743a0a8dcfca863e7850b
Rust
ijanos/euler-rust
/src/euler18.rs
UTF-8
1,090
3
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cmp; const INPUT: &'static str = r#"75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33 47 32 37 16 94 29 53 71 44 65 25 43 91 52 97 51 14 70 11 33 28 77 73 17 78 39 68 17 57 91 71 52 38 17 14 91 43 58 50 27 29 48 6...
true
5c039672205ee4f57b61d519e219e11810536693
Rust
MehdiHAJJAM/Projet_IOT
/nkeys/src/bin/nk/main.rs
UTF-8
8,007
2.546875
3
[ "Apache-2.0" ]
permissive
extern crate serde_json; use nkeys::{self, KeyPair, KeyPairType, receive_stream, send_stream, verify_seed}; use serde_json::json; use serde_json::{Value}; use serde::{Deserialize, Serialize}; use std::error::Error; use std::fmt; use std::fs; use std::str::{FromStr, from_utf8}; use structopt::clap::AppSettings; use str...
true
8b963db37a4e12c24aaacb8367edb08581fccc18
Rust
forkkit/klask
/src/klask_ui.rs
UTF-8
3,813
2.65625
3
[ "MIT" ]
permissive
use cansi::{CategorisedSlice, Color}; use eframe::egui::{Color32, Label, Response, Style, TextEdit, Ui}; use linkify::{LinkFinder, LinkKind}; pub fn set_error_style(ui: &mut Ui) -> Style { let previous = (**ui.style()).clone(); let style = ui.style_mut(); style.visuals.widgets.inactive.bg_stroke.color = Co...
true
4976bb97fcc7d3e4f5d2f0226e74153ab72df171
Rust
krishna-veerareddy/fastdiv
/tests/test.rs
UTF-8
3,554
2.953125
3
[ "MIT" ]
permissive
extern crate rand; extern crate fastdiv; use rand::prelude::*; use rand::rngs::SmallRng; use std::panic; macro_rules! generate_test { ($Ty: ty, $DivisorTy: ident, $Iterations: expr, $TestFn: ident, $InvalidDivisors: expr) => { #[test] fn $TestFn() { let mut rng = SmallRng::from_rng(ran...
true
b247cf74aff266e40e2123a7cdf77f8139d0c369
Rust
popsky/talent-plan
/courses/rust/projects/project-1-solution/kvs/src/lib.rs
UTF-8
888
3.90625
4
[ "MIT", "CC-BY-4.0" ]
permissive
use std::collections::HashMap; /// A key-value store that support get,set,rm operations. /// /// # Examples /// /// ``` /// use kvs::KvStore; /// /// let mut kv = KvStore::new(); /// kv.set("foo".to_owned(),"bar".to_owned()); /// assert_eq!(kv.get("foo".to_owned()).unwrap(), "bar".to_owned()); /// kv.remove("foo".to_o...
true
80f29d66ae6d1a835d33cceb744de9dc891f03e8
Rust
szabgab/slides
/rust/examples/variables/immutable_string.rs
UTF-8
128
2.65625
3
[]
no_license
fn main() { let text = "Hello World!"; println!("{}", text); text = "Something else"; println!("{}", text); }
true
409d43e1f81c3350ace0a171b8d557c41598fcbe
Rust
irevoire/brust
/src/commands/roll.rs
UTF-8
785
2.546875
3
[]
no_license
use anyhow::anyhow; use serenity::framework::standard::{macros::command, Args, CommandResult}; use serenity::{model::channel::Message, prelude::Context}; #[command] #[description = r#"Roll dice"#] pub async fn roll(ctx: &Context, msg: &Message, args: Args) -> CommandResult { std::env::set_var("NO_COLOR", "true"); ...
true
07d5ad56e128f491e93cd5ec8bc8831ecd20b9ad
Rust
abbshr/rust_quiz
/src/main.rs
UTF-8
2,406
3.09375
3
[]
no_license
#![allow(unused)] use std::{ future::Future, pin::Pin, sync::{Arc, Mutex}, sync::mpsc::{channel, Sender, Receiver}, task::{Context, Waker, Poll}, thread, time::Duration, }; use futures::executor; use futures::future::join; pub struct ConsumerFuture { shared_state: Arc<Mutex<SharedStat...
true
de45064f9df039ad780ecb3b137485dd93d2ad19
Rust
Mokosha/pbrt_rust
/src/transform/animated.rs
UTF-8
21,240
2.78125
3
[]
no_license
use bbox::BBox; use bbox::Union; use geometry::point::Point; use geometry::vector::Vector; use quaternion::Quaternion; use ray::Ray; use ray::RayDifferential; use transform::matrix4x4::Matrix4x4; use transform::transform::ApplyTransform; use transform::transform::Transform; use utils::Lerp; macro_rules! check_mat { ...
true
6e68f10b9076a0906c62274559ca5a9e24813f2e
Rust
Kenec/pipe
/src/validator/file_validator.rs
UTF-8
716
2.6875
3
[ "MIT" ]
permissive
use crate::config::Config; use std::path::Path; use std::path::PathBuf; pub async fn file_path_validator(config: PathBuf) { // load the config let loader = Config::load(&config.as_path()).unwrap(); let files = loader.sources.files; // An array to hold non-existence paths let mut no_existent_path =...
true
a454693b6a73c0904fa3eadaf9ca513393d555d1
Rust
balena-io-modules/atomic-io
/libatomicio/src/platform/unix/mod.rs
UTF-8
2,718
3.1875
3
[]
no_license
#[cfg(target_os = "linux")] #[path = "linux.rs"] mod imp; pub use self::imp::*; pub use errors::*; use std::fs; use std::ffi::{CString, OsString}; use std::io; use std::os::unix::fs::MetadataExt; use std::os::unix::ffi::OsStringExt; use std::os::unix::io::{AsRawFd, FromRawFd}; use std::path::{Path, PathBuf}; use ni...
true
635d976221cb91480798faddc917dbe768994190
Rust
gnoliyil/fuchsia
/third_party/rust_crates/ask2patch/regex-automata/src/codegen.rs
UTF-8
3,295
2.59375
3
[ "BSD-2-Clause", "MIT", "Unlicense" ]
permissive
// This module is unused. It was written as an experiment to get a ballpark // idea of what state machines look like when translated to Rust code, and // in particular, an idea of how much code it generates. The implementation // below isn't optimal with respect to size, but the result wasn't exactly // small. At some ...
true
a3964cded8bd52a4ed670d633d9209860f636d1e
Rust
ISibboI/santa-game
/src/snowflakes.rs
UTF-8
3,654
2.53125
3
[]
no_license
use crate::assets::SantaAssets; use crate::levels::LevelCameraBoundary; use crate::physics::Position; use crate::TIME_STEP; use bevy::prelude::*; use noise::{BasicMulti, MultiFractal, NoiseFn, Seedable}; use rand::distributions::{Distribution, Uniform}; use rand::thread_rng; static SNOWFLAKE_DENSITY: f32 = 0.002; #[d...
true
0cb3538c15a6af6e2f5934f47ab11c5baf7789fc
Rust
ia7ck/competitive-programming
/AtCoder/abc223/src/bin/d/main.rs
UTF-8
1,228
2.71875
3
[]
no_license
use input_i_scanner::{scan_with, InputIScanner}; use join::Join; use std::cmp::Reverse; use std::collections::BinaryHeap; fn main() { let stdin = std::io::stdin(); let mut _i_i = InputIScanner::from(stdin.lock()); let (n, m) = scan_with!(_i_i, (usize, usize)); let mut g = vec![vec![]; n]; for _ in...
true
2a8e298fa5c4f54a9923e12091836f4e045035d6
Rust
sria91-rlox/rlox-8
/src/expr.rs
UTF-8
4,259
3.234375
3
[ "Unlicense" ]
permissive
use crate::tokens::Token; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub(crate) enum Expr { Identifier(Token), Literal(Token), Logical(Box<Expr>, Token, Box<Expr>), Grouping(Box<Expr>), Unary(Token, Box<Expr>), Binary(Box<Expr>, Token, Box<Expr>), Assignment(Token, Box<Expr>), Call(Bo...
true
156a434bbed9eeb441226674af99fb2e0c856da9
Rust
rust-lang/libm
/src/math/cos.rs
UTF-8
2,255
2.859375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */ // // ==================================================== // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. // // Developed at SunPro, a Sun Microsystems, Inc. business. // Permission to use, copy, modify, and distribute this // software is freely ...
true
08ce5ca905cfc20774a888ccaf18c76c207cfe13
Rust
ttys3/nvim-rs
/src/examples/quitting.rs
UTF-8
2,049
3.5
4
[ "LGPL-3.0-only", "MIT", "LGPL-2.1-or-later", "Apache-2.0" ]
permissive
//! # Quitting //! //! A very small example showing how to handle quitting an application. //! //! * Running as an rpc plugin, just have neovim close the channel corresponding //! to our plugin //! * When embedding neovim, do the same via a command, as shown in this //! example. Note that this final request _will_ rece...
true
9bf528188ebd707ffe252af15672c1c89a69998c
Rust
dhbradshaw/euler-rust
/src/common/factors.rs
UTF-8
2,354
3.484375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use common::primes::{PrimeIterator, is_prime}; pub struct FactorIterator { value: uint, current: uint, max: uint, } impl FactorIterator { pub fn new(value: uint, limit: uint) -> FactorIterator { FactorIterator { current: 0u, value: value, ...
true
e5d394481e7c839f0faa5c8ae0dfd4ef3a0e3666
Rust
bombless/bfvm-rs
/bencode/lib.rs
UTF-8
5,243
3.375
3
[]
no_license
use std::fmt::{Debug, Formatter, Error}; pub fn object<'a>(kind: &'a str, content: &'a [u8])->Vec<u8> { let mut ret = Vec::new(); ret.push(b'd'); ret.extend(byte_string(kind.as_bytes())); ret.extend(byte_string(content)); ret.push(b'e'); ret } pub fn byte_string(s: &[u8])->Vec<u8> { let mu...
true
b70cd0d4b7f825e9789ffa29103782be7aa50e25
Rust
DrSloth/Crabscript
/src/c1/base.rs
UTF-8
7,358
3.171875
3
[]
no_license
use std::{ hash::{Hash, Hasher}, sync::Arc, }; use crate::variables::ExecutionManager; /// Arguments taken by any function pub type Args = Vec<DayObject>; pub type RustFunction = Arc<dyn Fn(Args, &Arc<ExecutionManager>) -> DayObject>; pub type ThreadId = usize; /// The basic data inside a variable #[derive(C...
true
80d7bad36a0baa8bebffb0918480bcd0a897e42f
Rust
shino16/cp_rust
/src/graph/weighted.rs
UTF-8
677
2.921875
3
[ "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pub use super::*; pub trait WGraph: Graph { type W; fn adj_w(&self, v: usize, f: impl FnMut(usize, Self::W)); } impl WGraph for Vec<Vec<usize>> { type W = usize; fn adj_w(&self, v: usize, mut f: impl FnMut(usize, Self::W)) { self[v].iter().for_each(|&v| f(v, 1)); } } impl<W> Graph for Vec<V...
true
1523a5493552bc57078e821f7050a8e9072e4f18
Rust
arjunlalshukla/aurum_actors
/aurum_actors/src/testkit/failure_config.rs
UTF-8
970
2.703125
3
[]
no_license
use crate::core::Socket; use im; use serde::{Deserialize, Serialize}; use std::time::Duration; /// Dictates how messages should be dropped. pub enum FailureMode { /// Individual packets are either sent/dropped/delayed by individually generated amounts. Packet, /// Messages are either sent/dropped/delayed in full...
true
f6e1d56dd0dbd3af41ffff5162ebbc67e8b8df32
Rust
jgrillo/um32
/src/main.rs
UTF-8
19,442
3.1875
3
[ "MIT" ]
permissive
extern crate byteorder; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::{stdout, stdin, Cursor}; use std::{process, mem}; use byteorder::{ReadBytesExt, BigEndian}; const PROGRAM_ADDRESS: usize = 0; // extract a range of bits from a u32 fn extract_bits(value: u32, start: u32, n: u32) -> u32 { ...
true
d163e0dbaecbfca71e1d6af62fede10db49a44cf
Rust
TotalDarkness-NRF/LearningRust
/basics/src/enums.rs
UTF-8
2,508
4.34375
4
[]
no_license
enum IpAddrKind { V4, V6, } struct IpAddr { _kind: IpAddrKind, //unimportant for example address: String, } // You can put almost any kind of data within an enum enum IpAddress { V4(u8, u8, u8, u8), V6(String), } // We can implement traites like ToString for an enum impl ToString for IpAddress...
true
ac4ef41189bbbbf000cec033b16150f026ace6e5
Rust
maximecb/uvm
/ncc/src/parsing.rs
UTF-8
13,898
3.375
3
[ "CC0-1.0", "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
use std::fs; use std::fmt; #[derive(Debug, Copy, Clone)] pub struct SrcPos { line_no: u32, col_no: u32, } #[derive(Debug, Clone)] pub struct ParseError { pub msg: String, pub src_name: String, pub line_no: u32, pub col_no: u32, } impl ParseError { pub fn new(input: &Input, msg: &str) -> S...
true
051b9b820d69bdbf135bb4d79c1ed83a12a7e8a6
Rust
rust-lang/rust
/tests/ui/type-alias-impl-trait/cross_inference_rpit.rs
UTF-8
190
2.734375
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
// check-pass fn foo(b: bool) -> impl Copy { if b { return (5,6) } let x: (_, _) = foo(true); println!("{:?}", x); (1u32, 2u32) } fn main() { foo(false); }
true
4714a0b39fe68d3b683017b8bd50f0d1e4c577f1
Rust
Addisonbean/Homespring-rs
/src/river.rs
UTF-8
12,360
2.640625
3
[]
no_license
#[cfg(test)] extern crate gag; use std::rc::{Rc, Weak}; use std::cell::{RefCell, RefMut, Ref}; use tick::Tick; use salmon::{Salmon, Age, Direction}; use split_custom_escape::HomespringSplit; use program::Program; #[derive(Debug, PartialEq, Eq)] pub enum NodeType { Other(String), Hatchery, HydroPower, ...
true
623f55c7d20e38bde9ee18c5c707ecac2454c829
Rust
AdamSmith89/azure_devops_api
/src/azure_devops_client.rs
UTF-8
1,843
2.546875
3
[ "MIT" ]
permissive
use url::Url; use crate::errors::ApiError; pub struct AzureDevopsClient { pat: String, client: reqwest::blocking::Client, } impl AzureDevopsClient { pub fn new(pat: &str) -> AzureDevopsClient { AzureDevopsClient { pat: pat.to_owned(), client: reqwest::blocking::Client::bui...
true
1016a0b98c00f85bf191deb77ccc1c853de5ca49
Rust
sugyan/adventofcode
/2022/rust/src/bin/day01.rs
UTF-8
1,559
3.265625
3
[]
no_license
use aoc2022::Solve; use itertools::Itertools; use std::io::{BufRead, BufReader, Read}; struct Solution { sorted_calories: Vec<u32>, } impl Solution { fn sum_top_n(&self, n: usize) -> u32 { self.sorted_calories.iter().rev().take(n).sum() } } impl Solve for Solution { type Answer1 = u32; ty...
true
b84fade7990e2d2459988fe8ce3b8743e2363f04
Rust
Drakulix/wayland-rs
/wayland-client/src/event_queue.rs
UTF-8
12,871
2.734375
3
[ "MIT" ]
permissive
use {Implementable, Proxy}; use std::any::Any; use std::io::{Error as IoError, Result as IoResult}; use std::io::Write; use std::ops::{Deref, DerefMut}; use std::os::raw::{c_int, c_void}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicPtr}; pub use token_store::{Store as State, StoreProxy as StateProxy, ...
true
2a3dc0701deae0878958a27935d41a40ef506664
Rust
bbqsrc/jscore-rs
/jscore/src/types.rs
UTF-8
10,709
2.84375
3
[]
no_license
use javascriptcore_sys::*; use std::convert::TryFrom; use std::ffi::CString; use std::ops::Deref; use std::ptr::{null, null_mut}; macro_rules! retain_release { ($name:ident, $ffi_ref:ty, $retain_fn:tt, $drop_fn:tt) => { impl Drop for $name { fn drop(&mut self) { unsafe { $drop_f...
true
1b1876a957d228a3d77d3bad11be2c6227ad0d0d
Rust
forbesmyester/pipeawesome
/src/config.rs
UTF-8
50,259
2.96875
3
[]
no_license
use std::ffi::{ OsStr }; use std::path::Path; use std::iter::IntoIterator; use std::cmp::{ Ord, Ordering }; use std::collections::{ BTreeMap, HashMap, BTreeSet }; // TODO: Can BTree* be replaced by Hash* use petgraph::stable_graph::{ StableGraph, NodeIndex }; use petgraph::{ Direction }; use serde::Deserialize; #[deri...
true
a0409703434a7575b2ce9bb56b4ecf63abb29aab
Rust
jlbali/rust_lessons
/rust_prog_lang/chapter8/src/main.rs
UTF-8
4,482
3.96875
4
[]
no_license
use std::collections::HashMap; fn main() { // Vectors let mut v: Vec<i32> = Vec::new(); let w = vec![1,2,3,4,5]; v.push(4); v.push(5); let third = &w[2]; println!("The third element is {}", third); match w.get(2) { Some(elem) => println!("We obtain {}", elem), N...
true
8182266609b2ae6e7605985a604ce17b135878e2
Rust
dcbishop/rust-soundex
/tests/tests.rs
UTF-8
1,907
3.21875
3
[ "CC0-1.0" ]
permissive
extern crate collections; extern crate soundex; use soundex::Soundex; fn check_soundex(word: &str, expected: &str) { let soundex = Soundex::new(); assert_eq!(soundex.encode(word).as_slice(), expected); } #[test] fn soundex_encoding_retains_sole_letter_of_one_letter_word() { check_soundex("A", "A000"); } ...
true
1c6c7c2476d75dc8bb3113dd4213eb0bd4c5321b
Rust
infinyon/fluvio
/crates/fluvio-test/src/tests/multiple_partitions/consumer.rs
UTF-8
1,044
2.5625
3
[ "Apache-2.0" ]
permissive
use std::collections::HashSet; use fluvio_test_util::test_meta::environment::EnvDetail; use fluvio_test_util::test_runner::test_driver::TestDriver; use futures_lite::StreamExt; use fluvio::Offset; use super::MyTestCase; pub async fn consumer_stream(test_driver: &TestDriver, option: MyTestCase) { let consumer = te...
true
94144aa6ba8832a8360af434d96c7c205839b324
Rust
tahnok/advent2017
/rust/src/bin/day20_2.rs
UTF-8
1,828
3
3
[]
no_license
extern crate regex; use std::io; use std::io::Read; use regex::Regex; fn main() { let mut input = String::new(); let _ = io::stdin().read_to_string(&mut input); closest(input.trim()); } fn closest(input: &str) -> () { let re = Regex::new(r"-?\d+").unwrap(); let mut particles = Vec::new(); f...
true
dadd61b182062bc158e6bde9ae0142367dc84390
Rust
HMate/rumoeba
/src/player.rs
UTF-8
416
3.65625
4
[]
no_license
#[derive(Debug, PartialEq)] pub struct Player { name: String } impl Player { pub fn new(name: &str) -> Player { return Player { name: name.to_string() }; } pub fn name(&self) -> &String { return &self.name; } } #[cfg(test)] mod tests { use super::*; #[test] fn get_pl...
true
62e8a528ee1cd115ad2fc07e9ad045891899c80f
Rust
kele/foxy
/src/main.rs
UTF-8
1,555
2.828125
3
[ "MIT" ]
permissive
// Main modules of the program. mod http; mod write_to; use std::collections::HashMap; use std::net; use std::vec::Vec; use write_to::WriteTo; const PROXY_PORT: u16 = 4000; fn main() { let listener = net::TcpListener::bind(("127.0.0.1", PROXY_PORT)).unwrap(); loop { match listener.accept() { ...
true
0b2f3c90570bd00e13a51ab1faef4242ac1cb420
Rust
flegac/rust-mcts
/rust-tools/src/screen/drawer.rs
UTF-8
1,155
3.15625
3
[]
no_license
use itertools::Itertools; use screen::dimension::Dimension; pub trait Drawer: Dimension { fn put(&mut self, offset: usize, value: char); fn read(&self, offset: usize, size: usize) -> &[char]; fn read_mut(&mut self, offset: usize, size: usize) -> &mut [char]; fn get(&self, offset: usize) -> &char { ...
true
497986ce01b72cfae3edc55f6b0900acde6da0cf
Rust
vanam/rust2llvm
/examples/08_complex.rs
UTF-8
1,699
3.265625
3
[ "MIT" ]
permissive
static RANDOM_SEED: i32 = 3; // random seed = 3, other values possible const N: i32 = 44448853; // we assume that n is not a large prime fn abs_val(a: i32) -> i32 { // if as a expression and expression as a implicit return statement if a > 0 { a } else { -a } } // returns (a ...
true
140d9c1be4871fd9bdc890c26fa031c5104e6021
Rust
iliayar/ITMO
/Term7/sd/HW-8/src/lib/clock.rs
UTF-8
847
2.921875
3
[]
no_license
use chrono::NaiveDateTime; pub trait Clock { fn now(&self) -> NaiveDateTime; } pub struct NormalClock {} impl NormalClock { pub fn new() -> Self { Self {} } } impl Clock for NormalClock { fn now(&self) -> NaiveDateTime { chrono::Local::now().naive_local() } } pub struct SetableC...
true
a1602378af3e791980e3d101a2ae9acad4ca1c8f
Rust
chappjc/secp256kfun
/secp256kfun/src/xonly.rs
UTF-8
6,037
3.359375
3
[ "0BSD" ]
permissive
use crate::{ backend::{self, BackendXOnly, TimeSensitive}, hash::HashInto, marker::*, Point, Scalar, }; use rand_core::{CryptoRng, RngCore}; /// An `XOnly` is the compressed representation of a [`Point<EvenY,S,Z>`] which /// only stores the x-coordinate of the point. /// /// Using a `Point<EvenY,..>` i...
true
1fb1f9f98a790d556dcbb86e8c3113075d2344c5
Rust
Notnaton/raytraced-weekend
/src/vec3.rs
UTF-8
5,191
3.21875
3
[]
no_license
#![allow(dead_code)] use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, MulAssign, Div, DivAssign, Deref, DerefMut, Neg}; use crate::{utils::*}; pub type Point3 = Vec3; pub type Color = Vec3; #[derive(Debug, PartialEq, Clone, Copy)] pub struct Vec3 ([f64; 3]); impl Vec3 { pub fn new() -> Self { Self (...
true
a4c938409b7a2421ccdfa3dbbedcafce668fb60a
Rust
raphamorim/rio
/rio/src/crosswords/grid/mod.rs
UTF-8
16,884
2.96875
3
[ "MIT" ]
permissive
pub mod resize; pub mod row; pub mod storage; #[cfg(test)] mod tests; use crate::crosswords::pos::Pos; use crate::crosswords::square::Flags; use crate::crosswords::square::ResetDiscriminant; use crate::crosswords::Cursor; use crate::crosswords::{Column, Line}; use row::Row; use std::cmp::{max, min}; use std::ops::{Bo...
true
eb570f9f3a159f0632863ca3d01ce8d487650128
Rust
Ujang360/dtn7-rs
/src/core/application_agent.rs
UTF-8
996
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use bp7::{Bundle, EndpointID}; use log::{debug, info}; use std::collections::VecDeque; use std::fmt::Debug; pub trait ApplicationAgent: Debug { fn eid(&self) -> &EndpointID; fn push(&mut self, bundle: &Bundle); fn pop(&mut self) -> Option<Bundle>; } #[derive(Debug, Clone, PartialEq)] pub struct SimpleAppl...
true
59531aaaf3e4ba588ca075f8ae7a382bd9b9f062
Rust
headcrab-rs/headcrab
/tests/readmem.rs
UTF-8
2,717
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
//! This is a simple test to read memory from a child process. mod test_utils; #[cfg(target_os = "linux")] use headcrab::{symbol::RelocatedDwarf, target::UnixTarget, CrabResult}; static BIN_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/testees/hello"); // FIXME: this should be an internal impl detail #[c...
true
d5a916070caa2617cef89dc0201c519da9d8d1bd
Rust
Norbytus/redis-client
/src/lib.rs
UTF-8
8,094
3.25
3
[]
no_license
use std::{io::{BufRead, Cursor, Seek, SeekFrom, ErrorKind, Read, Write}, net::{TcpStream, ToSocketAddrs}}; ///Simple implementation for redis client by tcp stream const BULK_STRING_BYTE: u8 = 36; const INTEGER_BYTE: u8 = 58; const SIMPLE_STRING_BYTE: u8 = 43; const ERROR_STRING_BYTE: u8 = 45; const ARRAYS_BYTE: u8 = ...
true
c03726c45c5911d8e88ccc984e6510e11e6241f7
Rust
ExPixel/KeePass
/src/crypto/cipher/salsa20.rs
UTF-8
4,734
2.921875
3
[ "Apache-2.0" ]
permissive
use std::io::Read; use super::{CtrBlockCipher64, BlockCipher}; use crate::memutil::read32_le; pub type Salsa20Ctr = CtrBlockCipher64<Salsa20>; const SIGMA: [u32; 4] = [0x61707865, 0x3320646E, 0x79622D32, 0x6B206574]; pub struct Salsa20 { state: [u32; 16], } impl Salsa20 { pub fn new(key: &[u8], nonce: &[u8]...
true
1af64887ac57338bdc082392b8db3a5577d6bc7b
Rust
likr-sandbox/pinball
/src/main.rs
UTF-8
1,446
2.546875
3
[]
no_license
mod pages; mod pinball; use pages::game::GamePage; use pages::home::HomePage; use yew::prelude::*; use yew_router::prelude::*; #[derive(Routable, PartialEq, Clone, Debug)] pub enum Route { #[at("/")] Home, #[at("/game")] Game, } #[function_component(App)] fn app() -> Html { html! { <ion-a...
true
a389ca54dc3513624d3eadc55122dc998d78769a
Rust
kasyaar/hls_m3u8
/src/tags/media_playlist.rs
UTF-8
8,992
2.765625
3
[ "MIT" ]
permissive
use std::fmt; use std::str::FromStr; use std::time::Duration; use trackable::error::ErrorKindExt; use types::{PlaylistType, ProtocolVersion}; use {Error, ErrorKind, Result}; /// [4.3.3.1. EXT-X-TARGETDURATION] /// /// [4.3.3.1. EXT-X-TARGETDURATION]: https://tools.ietf.org/html/rfc8216#section-4.3.3.1 #[derive(Debug,...
true
1c4394bf1092bd1cb8eff51378d757efe592e7b1
Rust
srenauld/simxiv
/prelude/src/lib.rs
UTF-8
2,081
3.125
3
[]
no_license
extern crate math; extern crate rand; mod action; mod entity; mod effect; mod aura; mod damage; pub use aura::{AuraEffect, Aura, SkillType, DamageType}; pub use effect::Effect; pub use action::ConditionalAction; pub use entity::{Job, Entity, Status}; pub use action::{Action, ActionTarget}; use std::ops::{Add}; use st...
true
fd6bdd82831a73ad68babc209599ff101cc00423
Rust
simvux/aoc-2020
/day11/src/main.rs
UTF-8
4,970
3.421875
3
[]
no_license
use itertools::Itertools; use std::fmt; use std::io::BufRead; fn main() { let stdin = std::io::stdin(); let mut map = stdin .lock() .lines() .map(Result::unwrap) .fold(Map::new(), |m, line| m.with_line(line)); println!("{}", map.clone().part_one()); println!("{}", map....
true
3ac7100e66a4f97961ba94cf51b4641cdfae22a5
Rust
Robinbux/rust-server
/src/http/response.rs
UTF-8
758
2.9375
3
[]
no_license
use crate::enums::content_type::ContentType; use crate::enums::http_status_codes::HTTPStatusCodes; #[derive(Debug)] pub struct Response { pub content_bytes: Vec<u8>, pub content_type: ContentType, pub http_status_code: HTTPStatusCodes, } impl Response { pub fn new( content_bytes: Vec<u8>, ...
true
81387beaa4aa8ea86ef1b961f95461ad1a8c5594
Rust
gilescope/wasm-tools
/crates/wasmparser/src/readers/name_section.rs
UTF-8
7,846
2.5625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LLVM-exception" ]
permissive
/* Copyright 2018 Mozilla Foundation * * 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...
true
f8916ed4a2df11fa6b1cd2bab483a984344c3904
Rust
brooksmtownsend/decs-cloud
/shard-mgr/src/store.rs
UTF-8
2,137
2.671875
3
[ "Apache-2.0" ]
permissive
use decscloud_common as codec; use decscloud_common::shard::Shard; use guest::prelude::*; const SHARDS_KEY: &str = "decs:shards"; pub(crate) const NOT_FOUND: &str = "Not found"; pub(crate) fn get_shards(ctx: &CapabilitiesContext) -> Result<Vec<String>> { ctx.kv().set_members(SHARDS_KEY) } fn count_key(shard: &st...
true
9aa61470715455eef73b64c5d7058dbb12048156
Rust
JM4ier/rva
/src/parsed.rs
UTF-8
3,275
3.234375
3
[]
no_license
#[derive(PartialEq, Eq, Debug, Copy, Clone)] pub enum WireKind { /// Only accessible to the local scope Private, /// Accessible to the local scope and as an input in an instance Input, /// Accessible to the local scope and as an output in an instance Output, } #[derive(PartialEq, Eq, Debug)] pu...
true
65b1904e15afe67d2a004a45bd16bd183af9c9e7
Rust
vladinator1000/rust-gpu
/crates/rustc_codegen_spirv/src/linker/dce.rs
UTF-8
3,704
3.140625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Dead code elimination //! //! This pass removes any instruction that doesn't affect the module. It does so by considering all //! `OpEntryPoint` instructions to be "rooted", and then everything a rooted instruction touches is //! also rooted (done transitively). Then, any instruction not rooted is removed. It gets ...
true
5caa2aca8e907ac1de171ceb715a291a4e5f7a5b
Rust
f5xs-0000a/yasc_project
/src/environment/key_bindings.rs
UTF-8
2,925
2.828125
3
[]
no_license
use bidir_map::BidirMap; use piston_window::{ Button, Key, }; //////////////////////////////////////////////////////////////////////////////// #[derive(Hash, Debug, Copy, Clone, Eq, PartialEq)] pub enum BindRoles { BT_A, BT_B, BT_C, BT_D, FX_L, FX_R, KN_L_CW, KN_L_CCW, KN_R...
true
9def18ba364d959b101cf0dbd3d90b8a85dc1c98
Rust
msoermc/rmc-core-2018-2019
/src/builder/launch.rs
UTF-8
1,376
2.703125
3
[]
no_license
use std::thread; use rocket::Rocket; use crate::benchmarking::ControllerBench; use crate::framework::{Runnable, CompositeRunnable}; use crate::mechatronics::controller::RobotController; use crate::builder::robot::Robot; pub struct RobotLauncher { controller: RobotController, bfr: Rocket, bench: Option<Co...
true
8f5ede2e4bbea5865d89ddf04e46ab004b015048
Rust
OliveBloom/everfree-outpost
/src/server/script/data.rs
UTF-8
6,255
2.546875
3
[]
no_license
use types::*; use data::Data; use python::{PyBox, PyResult}; use super::Pack; use super::rust_ref::{RustRef, RustRefType}; macro_rules! data_ref_func { ( $($all:tt)* ) => ( rust_ref_func!(Data, $($all)*); ); } define_python_class! { class DataRef: RustRef { type_obj DATA_REF_TYPE; initialize...
true
3a18119a64db367bc2e2344964502c1f465669ed
Rust
roynalnaruto/core
/crates/sol-macro/src/expand/type.rs
UTF-8
7,420
2.875
3
[ "Apache-2.0", "MIT" ]
permissive
//! [`Type`] expansion. use super::ExpCtxt; use crate::expand::generate_name; use ast::{EventParameter, Item, Parameters, Type, TypeArray, VariableDeclaration}; use proc_macro2::{Literal, TokenStream}; use quote::{quote, quote_spanned, ToTokens}; use std::{fmt, num::NonZeroU16}; /// Expands a single [`Type`] recursiv...
true
0e345433bd3640df850f07cb5d552d647cf2b986
Rust
rumbarum/study-rust
/Ch.4/sample3/src/main.rs
UTF-8
264
3.671875
4
[ "MIT" ]
permissive
fn main() { let s = String::from("hello"); take_ownership(s); let x = 5; makes_copy(x); println!("Hello, world!"); } fn take_ownership(string:String) { println!("{}", string) } fn makes_copy(integer:i32) { println!("{}", integer) }
true
6a7caf6bf6bb1b2676e6820c15036547467d5540
Rust
skyscribe/jira-reporter
/src/checkers/ca/timeline.rs
UTF-8
4,496
2.796875
3
[]
no_license
extern crate itertools; use std::fmt::format; use std::fs::File; use std::io::{BufWriter, Write}; use self::itertools::{Itertools, MinMaxResult}; use super::caitem::CAItem; struct TimeLineInfo { start_first: u32, start_last: u32, end_first: u32, end_last: u32, lead_time: u32, } ...
true
a8670bea972cb441cf023384000dbd8be3d55336
Rust
alexandru-calinoiu/rustician
/variables/src/main.rs
UTF-8
502
3.53125
4
[]
no_license
const MAX_NUMBER_OF_POINTS: u32 = 100_000; fn main() { let mut x = 5; println!("The value of x is {}", x); x = 6; println!("The value of x is {}", x); println!("The max number of points is {}", MAX_NUMBER_OF_POINTS); let tup: (i32, f64, u8) = (600, 6.4, 1); let (_x, y, _z) = tup; print...
true
7c14d59ae4059dca62b984c5941c338de30aa240
Rust
derekjw/hearts
/src/card/mod.rs
UTF-8
1,399
3.3125
3
[ "Apache-2.0" ]
permissive
pub mod dto; mod suit; mod rank; pub use card::suit::Suit; pub use card::rank::Rank; use std::fmt; use std::collections::BTreeSet; #[derive(Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy)] pub struct Card { pub suit: Suit, pub rank: Rank, } impl Card { pub fn new(suit: Suit, rank: Rank) -> Card { ...
true
5b84fc52985563f231d4c92941ea5b44141b749f
Rust
nathanmcmillan/scroll-and-sigil-rust
/client/src/app.rs
UTF-8
8,452
2.578125
3
[]
no_license
use crate::network; use crate::webgl; use crate::webgl::buffer::WebGlRenderBuffer; use crate::webgl::system::WebGlRenderSystem; use crate::webgl::texture::Texture; use sigil::game::game::Game; use sigil::map::sector::Sector; use sigil::math::matrix; use sigil::render::render; use sigil::render::sprite::Sprite; use sigi...
true
172798049f361e4e59f30d11d7574d4e1c76c031
Rust
SnoozeTime/spacegame
/src/core/transform.rs
UTF-8
4,953
3.09375
3
[]
no_license
use glam::{Mat3, Mat4, Quat, Vec2}; use log::debug; use serde_derive::{Deserialize, Serialize}; use std::collections::VecDeque; /// Transform of an element to place it on the screen #[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)] pub struct Transform { /// Translation along x-y pub translation: ...
true
3013a08a166399d1f4f0778dc655065ec3d590aa
Rust
sprajagopal/rusting
/ownership/src/main.rs
UTF-8
254
3.609375
4
[]
no_license
fn taking_over(s: String){ println!("Just printing {}", s); } fn main() { println!("Hello, world!"); let s = String::from("something"); taking_over(s); println!("Can I still use s here? Trying to print..."); println!("{}", s); }
true
23e82e9a27507cfe309a0ae07a79b3e13bad49d3
Rust
chronium/aatbe-lang
/parser/src/parser/atom.rs
UTF-8
8,392
3.03125
3
[ "MIT" ]
permissive
use crate::{ ast::{AtomKind, Boolean, FloatSize, IntSize, PrimitiveType}, parser::{ParseError, ParseResult, Parser}, token, token::{Keyword, Symbol, Type}, }; impl Parser { fn parse_boolean(&mut self) -> Option<AtomKind> { let token = self.next(); if let Some(tok) = token { ...
true
94f721eb6854d2280807cb7f23e1fbed2e2495c2
Rust
azasypkin/kroneum
/sw/firmware/api/src/system/system_hardware.rs
UTF-8
986
2.546875
3
[ "MIT" ]
permissive
use adc::ADCHardware; use beeper::PWMBeeperHardware; use buttons::ButtonsHardware; use flash::FlashHardware; use radio::RadioHardware; use rtc::RTCHardware; use timer::TimerHardware; use usb::USBHardware; /// Describes the SystemControl hardware management interface. pub trait SystemHardware: ADCHardware + But...
true
689a4fb9349a715e0596659a72cba9c39d568733
Rust
Naviigator/AdventOfCode2020
/src/day6.rs
UTF-8
1,950
3.25
3
[]
no_license
use std::collections::HashSet; fn parse_input(sample_data: bool) -> Parser { let mut parser = Parser::new(); crate::filehelper::read_file(6, sample_data, &mut |s: String| parser.parse_string(s)); parser } pub fn exec1(sample_data: bool) { let parser = parse_input(sample_data); let result : usize ...
true
5f5c4e15fc43a56c490be4cfd96d963e671dba73
Rust
nushell/nushell
/src/tests/test_regex.rs
UTF-8
1,738
3.046875
3
[ "MIT" ]
permissive
use crate::tests::{fail_test, run_test, TestResult}; #[test] fn contains() -> TestResult { run_test(r#"'foobarbaz' =~ bar"#, "true") } #[test] fn contains_case_insensitive() -> TestResult { run_test(r#"'foobarbaz' =~ '(?i)BaR'"#, "true") } #[test] fn not_contains() -> TestResult { run_test(r#"'foobarbaz'...
true
c4eb2021fb5e8b9585d342ff0c0dbedb933f284c
Rust
danicampa90/helmod-graphviz
/src/grammar_tests.rs
UTF-8
1,758
3.03125
3
[ "Unlicense" ]
permissive
use crate::grammar; #[test] fn test_numbers() { assert!(grammar::ObjectParser::new().parse("{x=42}").is_ok()); assert!(grammar::ObjectParser::new().parse("{x=-42}").is_ok()); assert!(grammar::ObjectParser::new().parse("{x=0}").is_ok()); assert!(grammar::ObjectParser::new().parse("{x=-1}").is_ok()); ...
true
8d33c45c534ba4a7211ad8d8e40fabc7fe5509d0
Rust
4IREAcademy/4ire_Homework1
/homework1_lib/src/lib.rs
UTF-8
572
2.953125
3
[]
no_license
pub mod area; pub mod volume; #[cfg(test)] mod tests { use crate::area::{find_area, AreaOf}; use std::f32::consts::PI; use crate::volume::{find_volume, VolumeOf}; #[test] fn area_works() { assert_eq!(find_area(AreaOf::Circle {radius:2.0}), 4.0*PI); assert_eq!(find_area(AreaOf::Rect...
true
31404b7cd755895d90ccc2cf729ec605ade40a6e
Rust
madprops/schoon
/src/main.rs
UTF-8
1,382
2.640625
3
[ "Apache-2.0" ]
permissive
pub const VERSION: &str = "v1.1.0"; mod macros; mod args; mod other; use crate:: { args:: { check_args, Args, }, }; use std:: { fs:: { self, File, }, path::PathBuf, }; use zip::ZipArchive; // Start of the program fn main() { schoon(check_args()); } // Main ...
true
60daa7c0e930cc214a08e84525fe44b181a744a4
Rust
davidcelis/advent-of-code-2017
/01-inverse-captcha/src/main.rs
UTF-8
1,231
3.5625
4
[]
no_license
const INPUT: &'static str = include_str!("input.txt"); fn main() { let input = parse_input(INPUT); println!("Part 1: {}", solve(&input, 1)); println!("Part 2: {}", solve(&input, input.len() / 2)); } fn solve(numbers: &[u32], offset: usize) -> u32 { numbers.iter(). zip(numbers.iter().cycle().s...
true
d368211106790975b2ab300c43d7bbdde0eb9e64
Rust
kalaninja/algorithmic-toolbox
/week6_dynamic_programming2/3_maximum_value_of_an_arithmetic_expression/rust/src/main.rs
UTF-8
2,127
3.375
3
[]
no_license
// #[derive(Debug, PartialEq)] enum Op { Plus, Minus, Multi, } impl Op { fn apply(&self, x: i64, y: i64) -> i64 { match self { Op::Plus => { x + y } Op::Minus => { x - y } Op::Multi => { x * y } } } fn from_char(ch: char) -> Self { ma...
true
494017fd40d71da1748e49ceba0caee8f2112888
Rust
isgasho/aquatic
/aquatic_http/src/lib/network/utils.rs
UTF-8
1,903
2.5625
3
[ "Apache-2.0" ]
permissive
use std::fs::File; use std::io::Read; use std::net::SocketAddr; use anyhow::Context; use native_tls::{Identity, TlsAcceptor}; use socket2::{Domain, Protocol, Socket, Type}; use crate::config::TlsConfig; pub fn create_tls_acceptor(config: &TlsConfig) -> anyhow::Result<Option<TlsAcceptor>> { if config.use_tls { ...
true
346bd731f43396276bf10074b89fc7c1995fd8af
Rust
zbrdge/mre
/model.rs
UTF-8
8,214
2.609375
3
[ "MIT" ]
permissive
use elasticsearch::{ Client, JsonObjectBuilder, SearchBuilder, }; pub struct Error { code: uint, msg: ~str, } impl Error: to_str::ToStr { pure fn to_str() -> ~str { fmt!("[%u] %s", self.code, self.msg) } } impl Error: ToBytes { fn to_bytes(lsb: bool) -> ~[u8] { self.to_str().to_bytes(lsb)...
true
c0183f2bb392bcf19ef41d3fe2ef48eed315ec30
Rust
cromo/aristid
/src/main.rs
UTF-8
7,288
2.75
3
[]
no_license
use std::fmt; fn main() { run_algae(); run_fractal_tree(); run_koch_curve(); run_parametric(); run_interpreted_dragon_curve(); } fn to_string<T: fmt::Display>(system: &aristid::compiled::LSystem<T>) -> String { system .symbols .iter() .map(|s| s.to_string()) .co...
true
0d7f353c3b5dc0404f8f1a74901da6d96a4a2cf6
Rust
crazyrex/sops
/functional-tests/src/lib.rs
UTF-8
15,927
2.84375
3
[]
no_license
extern crate tempdir; extern crate serde; extern crate serde_json; extern crate serde_yaml; #[macro_use] extern crate lazy_static; #[macro_use] extern crate serde_derive; #[cfg(test)] mod tests { extern crate serde; extern crate serde_json; extern crate serde_yaml; use std::fs::File; use std::io::...
true
236082c0aff63148f7f2c1b822838ff25421495f
Rust
stackcats/codewars
/5kyu/josephus_survivor.rs
UTF-8
127
2.53125
3
[]
no_license
fn josephus_survivor(n: i32, k: i32) -> i32 { let mut p = 0; for i in 2..=n { p = (p + k) % i; } p + 1 }
true
564d2a050925d2e6dc3090a9320f505218202841
Rust
EFanZh/LeetCode
/src/problem_0718_maximum_length_of_repeated_subarray/mod.rs
UTF-8
619
3.125
3
[]
no_license
pub mod binary_search; pub trait Solution { fn find_length(nums1: Vec<i32>, nums2: Vec<i32>) -> i32; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ((&[1, 2, 3, 2, 1] as &[_], &[3, 2, 1, 4, 7] as &[_]), 3), ((&[0, 0, 0, 0, 0]...
true
26403baebcec13244ec3bdb2a5941737c165f45a
Rust
AlterionX/benxu-dev
/crypto/src/token/paseto/v1/local/encryption.rs
UTF-8
4,876
2.796875
3
[ "MIT" ]
permissive
//! Collection of structs for decryption of the PASETO token. use super::local_prelude::*; pub(super) struct SerializedRandToken { pub(super) msg: Vec<u8>, pub(super) footer: Option<Vec<u8>>, randomness: Randomness, } pub(super) struct PrimedToken { msg: Vec<u8>, footer: Option<Vec<u8>>, nonce:...
true
bbe09464221bde6d749630292df88705e77ecb21
Rust
shadowmint/relay
/crates/relay-analytics/src/isolates/analytics_service/analytics_events.rs
UTF-8
492
2.5625
3
[]
no_license
use futures::sync::oneshot::Sender; use std::collections::HashMap; use crate::analytics_error::AnalyticsError; pub enum AnalyticsEventType { AnalyticsEvent(String, i32), AnalyticsQuery(AnalyticsQueryType), } pub enum AnalyticsQueryType { /// (Regex filter, promise) AnalyticsQueryLabels(Option<String>,...
true
124d3a60257cbec8e05ec4f3ad7827027efd668e
Rust
Takashiidobe/minus
/src/error.rs
UTF-8
3,392
2.984375
3
[ "MIT", "Apache-2.0" ]
permissive
//! Provides error types that are used in various places //! //! Some types provided are just present there to avoid leaking //! upstream error types #[cfg(feature = "static_output")] #[cfg_attr(docsrs, doc(cfg(feature = "static_output")))] #[allow(clippy::module_name_repetitions)] #[allow(clippy::useless_attribute)] ...
true
bef44ee29cf6ad9f13357096d116d7a5e9007fbd
Rust
sarvex/RustAlgorithms
/src/data_structures/segment_tree.rs
UTF-8
2,561
3.5625
4
[ "MIT" ]
permissive
/// This stucture implements a segmented tree that /// can efficiently answer range queries on arrays. pub struct SegmentTree<T: Default + Ord + Copy> { len: usize, buf: Vec<T>, op: Ops, } pub enum Ops { Max, Min, } impl<T: Default + Ord + Copy> SegmentTree<T> { /// function to build the tree ...
true
465df2ba53228648753e2f220984ec9a5f23aa10
Rust
rbalicki2/smithy_todolist
/src/home.rs
UTF-8
1,429
2.671875
3
[]
no_license
use crate::types::{ InputString, Ref, TodoList, TodoLists, }; use smithy::{ smd, types::{ Component, SmithyComponent, }, }; use std::{ cell::RefCell, rc::Rc, }; pub fn render_home_page<'a>( todo_lists: &'a mut TodoLists, (input_dom_ref, input_text): &'a mut (Ref, InputString), ) -> Smithy...
true
33f7c78ce0f0203c9dba9f7bdd3b1f863c2d5cbf
Rust
xy-plus/ycore
/kernel/src/loader.rs
UTF-8
2,895
2.5625
3
[]
no_license
use xmas_elf::{ program::{Flags, ProgramHeader, SegmentData, Type}, sections::SectionData, ElfFile, }; fn relocate(elf: &ElfFile, base: usize) -> Result<(), &'static str> { let data = elf .find_section_by_name(".rela.dyn") .ok_or(".rela.dyn not found")? .get_data(elf) .m...
true
b152e610b526b8933e4f4552b4c2a7fe9feec00a
Rust
MrAnno/syslog-ng-rust-modules
/syslog-ng-rs/syslog-ng-common/src/mock.rs
UTF-8
322
2.75
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use Pipe; use LogMessage; pub struct MockPipe{ pub forwarded_messages: Vec<LogMessage> } impl MockPipe { pub fn new() -> MockPipe { MockPipe{ forwarded_messages: Vec::new()} } } impl Pipe for MockPipe { fn forward(&mut self, msg: LogMessage) { self.forwarded_messages.push(msg); } ...
true
21980e93fa57ecbac16e83a2d6aa813291f273fc
Rust
killertux/number-5
/src/phrases/mod.rs
UTF-8
4,112
3.09375
3
[]
no_license
use rand::seq::SliceRandom; use serde::Serialize; #[derive(Serialize)] pub struct Phrase { message: String, } pub async fn get_phrase() -> Result<impl warp::Reply, std::convert::Infallible> { Ok(warp::reply::json(&Phrase { message: get_random_phrase(), })) } fn get_random_phrase() -> String { ...
true
7189e62b152970245ebde744aedd3a811a8346fa
Rust
Maix0/maix-chat2
/client/src/main.rs
UTF-8
13,924
2.703125
3
[]
no_license
use common::{Packet, PacketOwned}; use std::error::Error; use tui::{ buffer::Buffer, layout::Rect, style::Style, text::{Span, Spans}, widgets::{Paragraph, StatefulWidget, Widget, Wrap}, }; extern crate common; extern crate crossbeam_channel; extern crate crossterm; extern crate tui; // use crossbea...
true
00fbca8c471a4c944dd80b9fd074e4d5b74da176
Rust
sullvn/ffuu
/html-parse/src/parse/parse_comment.rs
UTF-8
1,285
3.234375
3
[]
no_license
use nom::{ bytes::complete::{tag, take_until}, sequence::tuple, IResult, }; use crate::types::HTMLPart; /// Parse HTML comment /// /// Is forgiving of comments with bad contents which don't fit the spec. /// /// Spec: https://html.spec.whatwg.org/multipage/syntax.html#comments /// pub fn parse_comment_par...
true
9e95a885ef10cb638442d3a488aeb0661885aae9
Rust
ericmdantas/rust-playground
/src/main.rs
UTF-8
128
2.8125
3
[]
no_license
struct P { x: i32, y: i32, } fn main() { let result = P{x:1,y:2}; println!("playground, {} / {}!", result.x, result.y); }
true
94450778eeab5eca744c0d00e45a692b605dbc9e
Rust
technic/fluent-templates
/templates/src/loader/tera.rs
UTF-8
2,501
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
use fluent_bundle::FluentValue; use serde_json::Value as Json; use snafu::OptionExt; use std::collections::HashMap; use unic_langid::LanguageIdentifier; use crate::Loader; const LANG_KEY: &str = "lang"; const FLUENT_KEY: &str = "key"; #[derive(Debug, snafu::Snafu)] enum Error { #[snafu(display("No `lang` argumen...
true