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
c6360593d8a7d22dedcc7693e6dea25fabd30553
Rust
makepad/makepad
/libs/objc-sys/src/declare.rs
UTF-8
11,675
3
3
[ "MIT" ]
permissive
/*! Functionality for declaring Objective-C classes. Classes can be declared using the `ClassDecl` struct. Instance variables and methods can then be added before the class is ultimately registered. # Example The following example demonstrates declaring a class named `MyNumber` that has one ivar, a `u32` named `_num...
true
c0dbc82028501f204b1b603b61852109c7b6809b
Rust
granbestiapop/massive-stream
/src/main.rs
UTF-8
4,441
2.5625
3
[]
no_license
use futures::stream::{StreamExt, TryStreamExt}; use tokio::io::AsyncBufReadExt; use tokio_util::compat::FuturesAsyncReadCompatExt; #[macro_use] extern crate lazy_static; mod repository; use repository::client::RestClient; const DEFAULT_CONCURRENT_REQUESTS: usize = 100; //const MAX_RETRIES: usize = 3; const DEFAULT_...
true
481a419a08315b91c01d4bad3fac157eb174175e
Rust
XuShaohua/nc
/src/calls/extattr_get_file.rs
UTF-8
710
2.5625
3
[ "Apache-2.0" ]
permissive
/// Get the value of the VFS extended attribute specified. pub unsafe fn extattr_get_file<P: AsRef<Path>>( path: P, attr_namespace: i32, attr_name: &str, data: &mut [u8], ) -> Result<ssize_t, Errno> { let path = CString::new(path.as_ref()); let path_ptr = path.as_ptr() as usize; let attr_nam...
true
875a4b5b3fc6481b1ed0e5254ae4a475385db119
Rust
yuushimizu/coord-rs
/src/point.rs
UTF-8
1,647
3.640625
4
[]
no_license
use crate::coord::{Coord, Primitive}; use num; use std::fmt; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub struct Point<T: Primitive> { x: T, y: T, } impl<T: Primitive> Point<T> { pub fn new(x: T, y: T) -> Self { Self { x, y } } /// # Examples /// ``` /// # use c...
true
a52813fe2ba73f9e45638404cb1d2032f5939f66
Rust
dima74/factorio-servers-statistics
/src/fetcher_get_games.rs
UTF-8
2,142
2.625
3
[]
no_license
use std::ops::Sub; use std::sync::mpsc; use std::thread; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use chrono::Utc; use crate::api; use crate::global_config::GLOBAL_CONFIG; use crate::state::TimeMinutes; use crate::util::duration_since; pub type FetcherOutput = (api::GetGamesResponse, TimeMinutes); pub fn ...
true
2fd1e9ca4c08261bc1a8e55505e21bb404f8233e
Rust
Forlos/vndb_rs
/tests/test_utils.rs
UTF-8
1,454
2.8125
3
[ "Unlicense" ]
permissive
use serde::de::DeserializeOwned; use std::io::prelude::*; use std::io::Write; use std::net::{SocketAddr, TcpListener, TcpStream}; use std::{fs::File, thread}; pub fn test_listener_with_response(mut buf: Vec<u8>) -> SocketAddr { buf.push(0x4); // Assigning port 0 requests the OS to assign a free port let li...
true
c93605217a6d697932fae2b067608e27852b4e5a
Rust
thane98/asset-pack-rs
/src/main.rs
UTF-8
3,367
2.9375
3
[]
no_license
mod unpacker; use anyhow::Context; use clap::{AppSettings, ArgGroup, Clap}; use std::path::{Path, PathBuf}; use mila::BinArchive; fn read_bin_archive_input(input_path: &Path) -> anyhow::Result<BinArchive> { let input = std::fs::read(input_path).context("Failed to read input file.")?; let input = if let Some(...
true
f04e6651441b74ddedcd780c4d710a702183612f
Rust
tari-project/tari
/infrastructure/tari_script/src/error.rs
UTF-8
3,136
2.53125
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2020. The Tari Project // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following // disclaimer. /...
true
7bcb5c7583ec0517f2fd1cf0064a163be8893f06
Rust
DrPeterVanNostrand/cargo-mlocktest
/src/main.rs
UTF-8
10,548
2.875
3
[]
no_license
#[cfg(test)] extern crate memsec; use std::collections::BTreeMap; use std::env; use std::fmt::{self, Display, Formatter}; use std::fs; use std::iter; use std::process::{Command, Stdio}; use std::str::{self, FromStr}; use std::sync::{Arc, Mutex}; use std::sync::atomic::{AtomicBool, Ordering}; use std::time::Duration; u...
true
e02fc768ca60fb09640b808ffdb55f19a65d9140
Rust
njeisecke/umya-spreadsheet
/src/structs/drawing/solid_fill.rs
UTF-8
3,583
2.796875
3
[ "MIT" ]
permissive
// a:solidFill use super::scheme_color::SchemeColor; use super::rgb_color_model_hex::RgbColorModelHex; use writer::driver::*; use quick_xml::Reader; use quick_xml::events::{Event, BytesStart}; use quick_xml::Writer; use std::io::Cursor; #[derive(Default, Debug)] pub struct SolidFill { scheme_color: Option<SchemeCo...
true
bf8bf683aab6ca184205dc3bd967a25400f1292c
Rust
In-line/calculator
/calculator-cli/src/main.rs
UTF-8
1,665
2.515625
3
[]
no_license
/* * Calculator * Copyright (c) 2019 Alik Aslanyan <cplusplus256@gmail.com> * * * This file is part of Calculator. * * Calculator is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either ver...
true
8c8a0b63999c54d431dd4bf51e0c5f49f049223a
Rust
psmietanaa/RustLisp
/bin/main.rs
UTF-8
314
2.65625
3
[]
no_license
use rust_lisp::interpreter::*; use std::env; fn main() { // Read command line arguments let args: Vec<String> = env::args().collect(); if args.len() == 1 { // Interactive REPL. repl(); } else { // Interpret a file. let path = &args[1]; file(path); } }
true
9b02925a77330145bc34b2ae68b5eff753359783
Rust
SpasZahariev/rust-tutorial
/src/loops.rs
UTF-8
537
3.96875
4
[]
no_license
pub fn run() { let mut count = 0; // Infinite Loop // loop { // count +=1; // println!("Number: {}", count); // if count == 20 { // break; // } // } // While loop (FizzBuzz) let mut count_two: u8 = 0; while count_two <= 12...
true
5317d660fa1e931596da484cb5a6c5a21f4a4b7a
Rust
vgene/bencher_scrape
/crates/crates/rust-buf-ref-reader/src/lib.rs
UTF-8
10,736
3.515625
4
[]
no_license
/*! Faster, growable buffering reader for when there's little to no need to modify data, nor to keep it alive past next read. `std::io::BufReader` works by copying data from its internal buffer into user-provided `Vec`/`String`, or, in case of `.lines()`, by emitting new heap-allocated `String` for each iteration. Whi...
true
7935c36c77ac9dad5a4494a0a93b17889d9c4526
Rust
rust-lang/crates.io
/src/util/tracing.rs
UTF-8
1,942
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
use sentry::integrations::tracing::EventFilter; use tracing::Level; use tracing::Metadata; use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::{prelude::*, EnvFilter}; /// Initializes the `tracing` logging framework. /// /// Regular CLI output is influenced by the optional /// [`RUST_LOG`](tracing_sub...
true
fade724799292006966ac4ec0b17d67634db94e5
Rust
serde-rs/json
/tests/regression/issue1004.rs
UTF-8
362
3.078125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![cfg(feature = "arbitrary_precision")] #[test] fn test() { let float = 5.55f32; let value = serde_json::to_value(float).unwrap(); let json = serde_json::to_string(&value).unwrap(); // If the f32 were cast to f64 by Value before serialization, then this // would incorrectly serialize as 5.5500001...
true
1f0fb72f296cc60960715ac935f00f4095a0ad17
Rust
rrybarczyk/fluids
/fluids/src/vortex.rs
UTF-8
713
3.078125
3
[ "CC0-1.0" ]
permissive
use crate::common::*; const VORTEX: u8 = 1; /// Cartesian: ψ = C A |y|² (a² - x² - |y|²) /// Cylindrical: ψ = C A (a² - r²) r² sin²θ /// domain -2 < x < 2 and -2 < y < 2 pub fn hills(m: usize, n: usize) -> Vec<usize> { // radius let a = 1; let u0 = 10; let A = 15/2 * u0 * 1/a^2; let mut z...
true
01e5d77554ff018947752c52bc91311dc8e04aea
Rust
leudz/shipyard
/src/mut.rs
UTF-8
1,567
3.453125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/// Tracks component modification. pub struct Mut<'a, T: ?Sized> { pub(crate) flag: Option<&'a mut u32>, pub(crate) current: u32, pub(crate) data: &'a mut T, } impl<'a, T: ?Sized> Mut<'a, T> { /// Makes a new [`Mut`], the component will not be flagged if its modified inside `f`. /// /// This is...
true
1f925dba2c5c7d4ba9690a69a8bea16b2bb2bb67
Rust
anonymous8923/occlum
/libos/src/libos/src/fs/inode_file.rs
UTF-8
7,554
2.53125
3
[ "BSD-3-Clause" ]
permissive
use rcore_fs::vfs::{FileSystem, FileType, FsError, INode}; use rcore_fs_mountfs::{MountFS, MNode}; use rcore_fs_ramfs::RamFS; use rcore_fs_sefs::SEFS; use std::fmt; use super::hostfs::HostFS; use super::sgx_impl::SgxStorage; use super::*; lazy_static! { /// The root of file system pub static ref ROOT_INODE: A...
true
5a0efa8204b25b0a13ad7576e6b7798b6042058c
Rust
sym233/leetcode_problems
/547. Number of Provinces/547. Number of Provinces.rs
UTF-8
1,131
2.578125
3
[]
no_license
impl Solution { pub fn find_circle_num(is_connected: Vec<Vec<i32>>) -> i32 { let n = is_connected.len(); let mut uf: Vec<usize> = (0..n).collect(); fn pa(mut uf: &mut Vec<usize>, i: usize) -> usize { if uf[i] == i { return i; } let mut pare...
true
1fc99ef1922a26f993fbeb7d60263f722ae1e6d3
Rust
jacobrec/jlisp
/src/evaluator/functions.rs
UTF-8
8,876
2.609375
3
[]
no_license
use crate::ast; use crate::bytecode; use std::collections::HashMap; const SAME_LINE: usize = 0; pub type InlineType = fn (&mut super::Evaluator, &ast::List<ast::Atom>) -> (); pub fn get_inlines() -> HashMap<String, InlineType> { let mut funs = HashMap::new(); funs.insert(String::from("+"), plus_inline as In...
true
6b6be762eba5f70ead12e2fa3c625f13fef41acf
Rust
Jimskapt/rust-book-fr
/FRENCH/listings/ch11-writing-automated-tests/listing-11-11/src/lib.rs
UTF-8
355
3.265625
3
[ "Apache-2.0", "MIT", "Unlicense", "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
pub fn ajouter_deux(a: i32) -> i32 { a + 2 } #[cfg(test)] mod tests { use super::*; #[test] fn ajouter_deux_a_deux() { assert_eq!(4, ajouter_deux(2)); } #[test] fn ajouter_deux_a_trois() { assert_eq!(5, ajouter_deux(3)); } #[test] fn cent() { assert_eq...
true
569c337b3f0a4443ad316e38499b49c760dc4a73
Rust
kaedroho/darkreign-rs
/src/sprite.rs
UTF-8
6,135
2.765625
3
[]
no_license
use std::io::{Cursor, Read, Write}; use byteorder::{LittleEndian, ReadBytesExt}; use image::ColorType; use image::png::PNGEncoder; use palette::SNOW_PALETTE; #[derive(Debug, PartialEq)] pub enum SpriteType { L, R, Shadow, } pub struct SpriteFile<'a> { data: &'a [u8], sprite_type: SpriteType, ...
true
75a8b152a49a780315a222c7f5e1466cb419c499
Rust
spacemeshos/svm
/crates/host/types/src/receipt/log.rs
UTF-8
771
3.359375
3
[ "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
use std::fmt; /// A log entry. Logs are generated during executing of transactions. /// Their main usage is for debugging / testing purposes. #[derive(PartialEq, Clone)] pub struct ReceiptLog { bytes: Vec<u8>, } impl ReceiptLog { /// New log entry pub fn new(bytes: Vec<u8>) -> Self { Self { bytes ...
true
0f38a4cfa9559dc98e1f63b64c901127ec73a728
Rust
entropitor/cpl-window-manager
/assignment/src/error.rs
UTF-8
2,057
3.3125
3
[]
no_license
//! This module provides the possible errors for our window managers use std::error; use std::error::Error; use std::fmt; use std::convert::From; use cplwm_api::types::{Window, WorkspaceIndex}; /// The errors that a window manager can return. /// /// [Error]: ../../cplwm_api/wm/trait.WindowManager.html#associatedtyp...
true
4b8630b4224664807aea48808778e8654dc5b318
Rust
minus3theta/contest
/cargo/abc235/src/bin/d.rs
UTF-8
1,145
2.703125
3
[]
no_license
#[allow(unused_imports)] use itertools::Itertools; #[allow(unused_imports)] use num::Integer; #[allow(unused_imports)] use proconio::derive_readable; use proconio::fastout; use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp; #[allow(unused_imports)] use std::col...
true
adaf3ad84526db38b11d215ea12dbf5a61ae7e6a
Rust
becheran/mlc
/src/markup.rs
UTF-8
1,139
3.046875
3
[ "MIT" ]
permissive
use serde::Deserialize; use std::str::FromStr; #[derive(Debug)] pub struct MarkupFile { pub markup_type: MarkupType, pub path: String, } #[derive(Debug, Clone, Copy, Deserialize)] pub enum MarkupType { Markdown, Html, } impl FromStr for MarkupType { type Err = (); fn from_str(s: &str) -> Res...
true
64fbb13a2eff6e20d1880557073bc0b93f6222c4
Rust
pixers/imaginator
/common/src/img/composite_op.rs
UTF-8
19,468
2.59375
3
[]
no_license
use magick_rust; use std::str::FromStr; #[derive(PartialEq,Eq,Debug,Fail)] #[fail(display = "Unknown composition operator: {}", _0)] pub struct UnknownCompositeOperator(String); #[derive(PartialEq,Eq,Debug,Copy,Clone)] pub enum CompositeOperator { Undefined, Alpha, Atop, Blend, Blur, Bumpmap, ...
true
dbaf194b0d0877f7fb86d7ead14a2e318138c8ec
Rust
losfair/cloudkernel
/shell/src/main.rs
UTF-8
763
2.53125
3
[]
no_license
use std::io::{Write, BufRead}; fn main() { unsafe { ck_runtime::hook::register_hooks(); ck_runtime::ip::start(); } let stdin = std::io::stdin(); let mut stdout = std::io::stdout(); let handle = stdin.lock(); let mut stdin_it = handle.lines(); loop { print!("> "); ...
true
a221533299d2752ab88fbcec4be273b992d0fe86
Rust
stv0g/k66
/src/lpuart0/ctrl.rs
UTF-8
83,500
2.84375
3
[ "MIT" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CTRL { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut ...
true
f8d8f873bbc8778eebef9d479a04f712ec66ed2d
Rust
wangchao0502/rust-leetcode
/src/p938_range_sum_bst.rs
UTF-8
1,913
3.203125
3
[]
no_license
#![allow(dead_code)] // use mods use leetcode_prelude::TreeNode; use std::cell::RefCell; use std::rc::Rc; pub struct Solution {} // problem description // answers impl Solution { // fn dfs(root: Option<Rc<RefCell<TreeNode>>>, low: i32, high: i32, sum: &mut i32) { // if let Some(root) = root { // ...
true
65f906b30b395b20887ad94a312e58599fa227c6
Rust
ForsakenHarmony/smali
/src/dex/types/id.rs
UTF-8
32,015
2.609375
3
[]
no_license
use std::{clone::Clone, marker::Copy, ops::Not}; use eyre::{bail, ensure, Result, WrapErr}; use crate::dex::{ asm::instruction::Instruction, parser::{ parse::{Sleb128, Uleb128}, Parse, ParseError, Parser, }, resolver::{Resolve, ResolveInto}, types::{ file::DexFile, refs::{IdItem, Idx, Ref}, }, }; c...
true
691266a25580a11b9aef2e0046a7e0eb9eb425e5
Rust
adharmad/rust-examples
/beginning-rust/arr3.rs
UTF-8
221
2.765625
3
[]
no_license
fn main() { // multi dimensional arrays let mut arr1 = [[0; 10]; 10]; for i in 0..arr1.len() { for j in 0..arr1[i].len() { print!("{} ", arr1[i][j]); } println!(); } }
true
f494205ab056ecf83e1ac03c6a5168476c6671c4
Rust
ayrat555/el_monitorro
/src/bot/commands/remove_global_filter.rs
UTF-8
1,269
2.734375
3
[ "MIT" ]
permissive
use super::Command; use super::Message; use super::Response; use crate::db::telegram; use diesel::PgConnection; use typed_builder::TypedBuilder; static COMMAND: &str = "/remove_global_filter"; #[derive(TypedBuilder)] pub struct RemoveGlobalFilter { message: Message, } impl RemoveGlobalFilter { pub fn run(&se...
true
fccb68939af82cb3e3394c8e425d12020a404d01
Rust
nushell/nushell
/crates/nu-plugin/src/serializers/mod.rs
UTF-8
2,118
2.609375
3
[ "MIT" ]
permissive
use crate::{ plugin::PluginEncoder, protocol::{PluginCall, PluginResponse}, }; use nu_protocol::ShellError; pub mod json; pub mod msgpack; #[doc(hidden)] #[derive(Clone, Debug)] pub enum EncodingType { Json(json::JsonSerializer), MsgPack(msgpack::MsgPackSerializer), } impl EncodingType { pub fn t...
true
06f42fbf8f6d86cd58d9cb1fd36b7f021696c121
Rust
DominicWrege/elenco
/src/model/preview/episode.rs
UTF-8
6,930
2.796875
3
[ "MIT" ]
permissive
use crate::time_date::{ parse_datetime_rfc822, parse_duration_from_str, serialize_option_datetime, DurationFormator, }; use chrono::offset::Utc; use chrono::DateTime; use reqwest::Url; use serde::Serializer; use std::convert::{TryFrom, TryInto}; use std::str::FromStr; #[derive(Debug, serde::Serialize)] #[serde(ren...
true
f57224c2e36e4cdbdf850a8070f92923ccd415d9
Rust
gengjiawen/leetcode
/DP/_1137_n_th_tribonacci_number.rs
UTF-8
992
3.890625
4
[]
no_license
// https://leetcode.com/problems/n-th-tribonacci-number // // The Tribonacci sequence T<sub>n</sub> is defined as follows: // // T<sub>0</sub> = 0, T<sub>1</sub> = 1, T<sub>2</sub> = 1, and T<sub>n+3</sub> = T<sub>n</sub> + T<sub>n+1</sub> + T<sub>n+2</sub> for n >= 0. // // Given `n`, return the value of T<sub>n</sub>...
true
9ae6436e6529a3976ff1fe37559036c45d539c8e
Rust
Zenithsiz/twitch-helix
/src/request/channels/info.rs
UTF-8
2,524
3.515625
4
[ "MIT" ]
permissive
//! Channel info request // Imports use crate::{helix_url, HelixRequest, HttpMethod}; /// Channel info request /// /// This request uses the `/channels` path /// to get information about a channel /// given their broadcaster id. /// /// # Examples /// ``` /// # use twitch_helix::request::channel::info::Request; /// #...
true
ef8750fccefb4c508d09873944edb1f919e42a09
Rust
shepmaster/advent-of-code-2018
/day-6/src/main.rs
UTF-8
4,509
3.078125
3
[ "MIT" ]
permissive
use itertools::Itertools; use std::collections::{BTreeMap, BTreeSet}; static INPUT: &str = include_str!("../input.txt"); type Error = Box<std::error::Error>; type Result<T, E = Error> = std::result::Result<T, E>; #[derive(Debug, Copy, Clone, PartialEq)] enum Nearest { One(Coord), Multiple, } impl Nearest { ...
true
9dec1b972bf2c54df8742f2c7e16be45d050450e
Rust
rick68/rust-trace
/libcore/iter/struct_RangeInclusive/range_inclusive.rs
UTF-8
7,286
3.171875
3
[ "MIT" ]
permissive
#![feature(core, step_trait, zero_one)] extern crate core; #[cfg(test)] mod tests { use core::iter::RangeInclusive; use core::iter::Step; use core::iter::range_inclusive; use core::clone::Clone; use core::num::One; use core::ops::Add; use core::cmp::PartialEq; use core::cmp::Orderi...
true
339e11c5737ea148abd531904f1c946e14adcaf6
Rust
cloudflare/lol-html
/c-api/src/string.rs
UTF-8
1,144
2.9375
3
[ "BSD-3-Clause", "CC-BY-SA-4.0" ]
permissive
use super::*; // NOTE: we don't use CStr and CString as the transfer type because UTF8 // string comming from both sides can contain interior NULLs. #[repr(C)] pub struct Str { data: *const c_char, len: size_t, } impl Str { pub fn new(string: String) -> Self { Str { len: string.len(), ...
true
df0dd3752c6e320aba3245cf8be97f3538df863f
Rust
jleedev/rad
/src/buffer.rs
UTF-8
3,823
2.921875
3
[]
no_license
use rusqlite; use tempdir::TempDir; use std::error; type Error = Box<error::Error>; pub struct Buffer { conn: rusqlite::Connection, tmp_dir: TempDir, } impl Buffer { pub fn new() -> Result<Self, Error> { let tmp_dir = TempDir::new_in("/var/tmp", "rad")?; let db_path = tmp_dir.path().join(...
true
7826a94d099632efec1208558d5734c228644423
Rust
irfansharif/nsim
/src/simulators.rs
UTF-8
16,471
3.296875
3
[]
no_license
use std::collections::VecDeque; use generators::Generator; use rand::{thread_rng, Rng}; use bit_vec::BitVec; use cbuffer::CircularBuffer; // Packet holds the value of the time unit that it was generated at and its length. #[derive(Clone, Copy, PartialEq, Debug)] pub struct Packet { pub time_generated: u32, pub...
true
e753d6412d00b9aa54071b9bc44339ecbd18a9b2
Rust
manuelpelloni/img-parts
/src/riff.rs
UTF-8
7,113
2.84375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use alloc::vec::Vec; use core::convert::TryInto; use core::fmt; use bytes::{Buf, BufMut, Bytes, BytesMut}; use crate::encoder::{EncodeAt, ImageEncoder}; use crate::util::{read_checked, read_u8_len4_array, split_to_checked}; use crate::{Error, Result}; // the 4 bytes signature const SIGNATURE: &[u8] = &[b'R', b'I', b...
true
22f9f43d0392e65640b141424a022cbf20eba587
Rust
ghzlatarev/rust_hash_map
/src/lib.rs
UTF-8
6,867
3.53125
4
[]
no_license
use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::mem; // low for testing const INITIAL_NBUCKETS:usize = 1; pub struct HashMap<K, V> { buckets: Vec<Vec<(K, V)>>, items: usize, } impl<K,V> HashMap<K,V> { pub fn new() -> Self { HashMap { // Initializ...
true
08ede4ffcc69c0ef15c600173dd2780dc59119fc
Rust
nakamurakyo/rust-practice
/rust_tour_sample_cargo/src/main.rs
UTF-8
362
3.484375
3
[ "Apache-2.0" ]
permissive
fn main() { println!("Hello, world!"); // x の型を推論 let x = 13; println!("{}", x); // x の型を指定 ※ 勿論シャドウイングも可能 let x: f64 = 3.14159; println!("{}", x); // mut というキーワードで可変変数に。 let mut y = 42; println!("{}", y); y = 13; println!("{}", y); }
true
9c35ad01ca14fede44a39715eff60d76ff739ade
Rust
cch123/test
/rust/mio_test/src/main.rs
UTF-8
3,967
3.09375
3
[]
no_license
use mio::event::Event; use mio::net::{TcpListener, TcpStream}; use mio::{Events, Interest, Poll, Registry, Token}; use std::io::{self, Read, Write}; use std::collections::HashMap; use std::str::from_utf8; const SERVER: Token = Token(0); const DATA: &[u8] = b"hello world\n"; fn main() -> io::Result<()> { let mut ...
true
cd599aee0c75e256f44072f1597af35e462e3d17
Rust
estk/log4rs
/src/append/console.rs
UTF-8
7,069
2.84375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! The console appender. //! //! Requires the `console_appender` feature. use derivative::Derivative; use log::Record; use std::{ fmt, io::{self, Write}, }; #[cfg(feature = "config_parsing")] use crate::config::{Deserialize, Deserializers}; #[cfg(feature = "config_parsing")] use crate::encode::EncoderConfig;...
true
50966bdc1a000f05903d157deb8d6fcb2f5ef44d
Rust
lukechampine/merkle
/rust/src/main.rs
UTF-8
1,738
3.15625
3
[]
no_license
use std::io::prelude::*; use std::fs::File; extern crate crypto; use crypto::digest::Digest; use crypto::sha2::Sha256; extern crate rustc_serialize as serialize; use serialize::hex::ToHex; const SEGSIZE: usize = 64; struct Stack<T: crypto::digest::Digest> { hash: T, elems: Vec<Elem>, } struct Elem { height: u32...
true
d51edee6aa7913537afffcce6af01cf7882503aa
Rust
mbark/aoc2019
/day1/src/main.rs
UTF-8
751
3.453125
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::{self, BufRead}; fn main() { let modules: Vec<usize> = io::BufReader::new(File::open("input.txt").unwrap()) .lines() .map(|s| s.unwrap().parse::<usize>().unwrap()) .collect(); let mass = first(&modules); println!("first {}", mass); println!("seco...
true
9851c7613482cc1afdb5fd84567bf23a0469ae0f
Rust
fabura/icu4x
/components/calendar/src/datetime.rs
UTF-8
656
2.953125
3
[ "Apache-2.0", "ICU", "MIT", "LicenseRef-scancode-unicode" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use crate::types::Time; use crate::{AsCalendar, Date}; /// A date+time for a given calendar /// /// This can work wi...
true
282d0647938ac092965fe8e52066350dba298594
Rust
AraragiRukasu/RustExample
/src/printers/common_printer.rs
UTF-8
163
2.75
3
[]
no_license
pub trait Printer { fn print(&self, message: &String) { println!("This output could not be printed, message length(bytes): {}", message.len()); } }
true
644d33000222f78f69ec70299f637d8d66f2e9b6
Rust
NicolenaStiles/rust_exercism
/src/bottles_of_beer/bottles_of_beer_singer.rs
UTF-8
1,664
3.671875
4
[]
no_license
// Module 5: // bottles of beer song // // sing_beer_song // prints the lyrics to the song "99 bottles of beer". // INPUT || beer_number : u8 // // 99 bottles of beer on the wall, 99 bottles of beer. // Take one down and pass it around, 98 bottles of beer on the wall. // // ... // // 2 bottles of beer on the wall, 2 b...
true
e98ea87fce2b4e055b156625713f939a3a2b98cd
Rust
BerhorShadowbuckle/gherkin-rust
/tests/cucumber.rs
UTF-8
512
2.671875
3
[ "Apache-2.0", "MIT" ]
permissive
#[macro_use] extern crate cucumber; use std::default::Default; pub struct MyWorld {} impl cucumber::World for MyWorld {} impl Default for MyWorld { fn default() -> MyWorld { MyWorld {} } } mod t { steps!(crate::MyWorld => { given "I just started" |_world, _step| { println!("HE...
true
cff38893a3104210dbcacdbbf888e2a68f7cf53b
Rust
muscad-io/MusCAD
/muscad-core/src/sealed/boolean/brep/connect.rs
UTF-8
2,482
2.609375
3
[]
no_license
use super::*; impl<T: Float> BooleanSolver<T> { pub fn connect_and_group_segments(&mut self, d: &mut BrepData<T>) { let mut segments = new_map(); segments.extend(d.segments.drain()); let mut endpoints = new_set(); for (v, set) in segments.iter() { if set.len() == 1 { ...
true
b40affc058e8edcb43374cf7c79cefed8d33ac6a
Rust
vcapra1/ta-toolbox
/project-grades/src/roster.rs
UTF-8
2,810
3.9375
4
[]
no_license
//! Code for reading the students' information from the roster file and processing it for easy //! lookup and storage of basic information. use std::fs::File; /// The types of errors that can be produced within and returned from this module. #[derive(Debug)] pub enum Error { RosterReadError, RosterFormatError...
true
8bf7ccf6c4c3829535273991bc38f406c1c4ead0
Rust
tianenchen/leetcode-rs
/src/offer/is_symmetric.rs
UTF-8
1,228
3.328125
3
[]
no_license
// Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } #[allow(dead_code)] impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { v...
true
58c9e9998bd85620747a275997287669611a9c67
Rust
ghishadow/scoop-rs
/crates/cli/src/cmd/hold.rs
UTF-8
502
2.703125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use scoop_core::{manager::AppManager, Config}; pub fn cmd_hold(matches: &clap::ArgMatches, config: &Config) { if let Some(name) = matches.value_of("app") { let app_manager = AppManager::new(config); if app_manager.is_app_installed(name) { match app_manager.get_app(name).hold() { ...
true
2fc4bab12d7aee8c5d3cc72eda0951c8afc6fb41
Rust
adamhammes/pokemon_go_data
/src/species/mod.rs
UTF-8
6,621
3.4375
3
[ "MIT" ]
permissive
//! Holds the [PokeSpecies](species/struct.PokeSpecies.html) constants. use evaluation::Level; use types::PokeType; mod generated_species; pub use self::generated_species::*; pub const NUM_SPECIES: u16 = 251; #[derive(Debug, Eq, PartialEq, Hash)] /// Information about a specific Pokemon species. pub struct PokeSpeci...
true
38d16e2f7cd8bd76d36af5bf004b69c61ef7e23f
Rust
ltfourrier/alexandrie-backend
/src/cfg/resolver.rs
UTF-8
1,656
3.0625
3
[ "Apache-2.0" ]
permissive
use crate::cfg::models::Configuration; use config::{Config, ConfigError, Environment, File}; use std::env; /// Try to read the program configuration from various sources. /// /// # Configuration sources /// /// The following configuration sources are accepted, in that order: /// * Through various files that may or ma...
true
95e1dc0591543f65122a92f76b75bf24a18065b5
Rust
ryuheechul/AdventOfCode2020
/day2/src/password.rs
UTF-8
3,057
3.75
4
[]
no_license
#[derive(Debug, PartialEq)] struct PasswordPolicy { min: u8, max: u8, charactor: char, } #[derive(Debug, PartialEq)] pub struct PasswordValidation { policy: PasswordPolicy, pw: String, } use std::convert::From; impl PasswordPolicy { fn validate_for(&self, pw: &str) -> bool { let count = pw.chars().fi...
true
69d4852898974884fd38a8454b91c5633ba61df4
Rust
input-output-hk/chain-wallet-libs
/wallet/src/transaction/builder.rs
UTF-8
5,311
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use super::witness_builder::WitnessBuilder; use crate::Settings; use chain_addr::Address; use chain_impl_mockchain::{ block::BlockDate, fee::FeeAlgorithm as _, transaction::{ Balance, Input, Output, Payload, SetAuthData, SetIOs, SetTtl, SetWitnesses, Transaction, TxBuilderState, }, v...
true
d4d02d060f0f287822f5e19ae4404ab6238a55ae
Rust
stm32-rs/stm32f1xx-hal
/src/dma.rs
UTF-8
21,083
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! # Direct Memory Access #![allow(dead_code)] use core::{ marker::PhantomData, sync::atomic::{compiler_fence, Ordering}, }; use embedded_dma::{ReadBuffer, WriteBuffer}; #[derive(Debug)] #[non_exhaustive] pub enum Error { Overrun, } #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Event { HalfT...
true
f6f53c6d1715eeade98074abed0f680cd5575752
Rust
immunant/rexpat
/src/string_pool.rs
UTF-8
12,172
2.734375
3
[ "MIT" ]
permissive
use crate::expat_external_h::XML_Char; use crate::lib::xmlparse::{ExpatBufRef, ExpatBufRefMut, XmlConvert}; use crate::lib::xmltok::{ENCODING, XML_Convert_Result}; use bumpalo::Bump; use bumpalo::collections::vec::Vec as BumpVec; use fallible_collections::FallibleBox; use libc::c_int; use std::cell::{Cell, RefCell}; ...
true
d0a31b58151a1ef0a20b4f8c0ef68691a75a9a3e
Rust
gitter-badger/genevo
/src/selection/truncation.rs
UTF-8
4,367
3.171875
3
[ "Apache-2.0", "MIT" ]
permissive
//! The `truncation` module provides selection methods that are merely based //! on the fitness values of the individuals but don't have any stochastic //! component. //! //! The provided `SelectionOp` implementations are: //! * `MaximizeSelector` use genetic::{Breeding, Fitness, Genotype}; use operator::{GeneticOpera...
true
3a48a8be9ae0cb6181ae6ef08c7583325127cbbb
Rust
siqueiraets/nesrust
/src/memory.rs
UTF-8
643
3.34375
3
[]
no_license
pub struct Memory { ram: [u8; 2048], } impl Memory { pub fn new() -> Memory { Memory { ram: [0; 2048] } } pub fn cpu_write(&mut self, address: u16, data: u8) { if address < 0x2000 { // println!("Write memory: {:#04X}: {:#02X}\n", address & 0x7FF, data); self.ram...
true
9ff483c87e6336c4723f25b5fd65960d2b353065
Rust
jace-ys/inslice
/src/bin/rowslc/main.rs
UTF-8
8,835
3.15625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::error::Error; use std::fs::File; use std::io::{self, BufRead, BufReader, BufWriter, Write}; use std::process; use clap::Parser; use inslice::filter::{Filter, FilterSet}; /// A command-line utility for filtering input text by rows and writing them to standard output #[derive(Parser)] #[clap( name = "rows...
true
bf42169fa7e4a95dcee1d9979d258769b0117913
Rust
Barandis/rust-c64
/src/devices/chips/ic7406.rs
UTF-8
11,514
3
3
[ "MIT" ]
permissive
// Copyright (c) 2021 Thomas J. Otterson // // This software is released under the MIT License. // https://opensource.org/licenses/MIT // Note that the imports for std::rc::Rc, std::cell::RefCell, and // crate::components::pin::Pin are only necessary because of the demo non-macro constructor // function. /// Pin assi...
true
a18fc2a34cebf141c2e123cf3505917041856634
Rust
stevej/rustled
/list_zipper.rs
UTF-8
5,170
3.1875
3
[ "MIT" ]
permissive
use std::list; use std::list::{List, Cons, Nil}; /** * A Huet Zipper built around @Lists. */ pub struct ListZipper<E: Copy> { hd: @List<E>, tail: @List<E> } trait Zipper<E: Copy> { pure fn go_left() -> self; pure fn go_right() -> self; pure fn at_begin() -> bool; pure fn at_end() -> bool; pure fn is_e...
true
a880e83d1691a55e6878eda9abd89f8704229e77
Rust
filippixavier/AoC2019
/src/days/day18.rs
UTF-8
7,983
3.03125
3
[ "MIT" ]
permissive
use std::error::Error; use std::fs; use std::path::Path; use std::collections::HashMap; use std::collections::HashSet; use std::collections::VecDeque; type Coordinate = (usize, usize); type Map = HashMap<Coordinate, Tile>; type Graph = HashMap<char, Node>; #[derive(Debug, PartialEq)] enum Tile { Empty, Wall,...
true
c9ecfb44a30b901e6c5be7d2eed7eef98e53737e
Rust
jLawsonT/dice_rust
/src/main.rs
UTF-8
1,527
3.546875
4
[]
no_license
use std::io; use rand::Rng; fn randomNumber(num: u32) -> u32 { let mut rng = rand::thread_rng(); let num1 = rng.gen_range(0, num); num1 } fn main() { println!("How many sides does your dice have? "); let mut n = String::new(); io::stdin() .read_line(&mut n) .expect("failed...
true
0796db3cd4f8ec21020e23deb7166182b156969b
Rust
mluluz/lighthouse
/eth2/utils/fisher_yates_shuffle/src/rng.rs
UTF-8
2,571
3.671875
4
[ "Apache-2.0" ]
permissive
use super::hashing::hash; const SEED_SIZE_BYTES: usize = 32; const RAND_BYTES: usize = 3; // 24 / 8 const RAND_MAX: u32 = 16_777_215; // 2 ** (rand_bytes * 8) - 1 /// A pseudo-random number generator which given a seed /// uses successive blake2s hashing to generate "entropy". pub struct ShuffleRng { seed: Vec<u8...
true
a0de648d19af20db0c8a6c3be8efbb542afc98a3
Rust
herblet/stomp-parser
/src/model/headers/macros.rs
UTF-8
7,476
2.84375
3
[ "MIT" ]
permissive
macro_rules! header_display { ( ) => { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { write!(f, "{}:{}", self.header_name(), self.value) } }; } macro_rules! header { ( $header:ident, $name:expr $(,$types:ty $(, $default:expr )?)? ) =>...
true
0567db454172a7b9cae075e0a7c1ec44732c106f
Rust
subscript-publishing/subscript-display
/src/macros.rs
UTF-8
2,479
2.765625
3
[]
no_license
#![allow(unused_macros)] // ---------------------- // Parsing related Macros // ---------------------- macro_rules! alt { ($e:expr $(,)*) => ( match $e? { Some(res) => Some(res), None => None, } ); ($e:expr, $($tt:tt)*) => ( match $e? { Some(res...
true
9da64b7f01dd2bbcbc7e83170262648dd49e2aea
Rust
mishaszu/learning-actix-web
/handler-basic/src/extractors.rs
UTF-8
1,005
3.15625
3
[ "MIT" ]
permissive
use actix_web::{get, post, web, HttpRequest, Result}; use serde::Deserialize; #[get("/data/{data_id}/{value}")] async fn extractor_1(web::Path((data_id, value)): web::Path<(u32, String)>) -> Result<String> { Ok(format!( "1) Extracted data id: {}, and data value: {}", data_id, value, )) } #[der...
true
db46e665b0e3857e466393500e33a834cc98d71d
Rust
nginnever/bellman-example
/bellman-example/src/main.rs
UTF-8
2,294
2.75
3
[]
no_license
extern crate bellperson; extern crate paired; extern crate rand; extern crate ff; use bellperson::{Circuit, ConstraintSystem, SynthesisError}; use bellperson::groth16::{Parameters}; use paired::{Engine}; use ff::{Field, PrimeField}; use std::fs::File; use std::io::prelude::*; mod mul; fn main() { //env_logger::init...
true
b29acd6fb74f0db72d35ef4f821f06e4accaef88
Rust
loewenheim/pueue
/client/display/log/json.rs
UTF-8
4,278
2.71875
3
[ "MIT" ]
permissive
use std::collections::{BTreeMap, HashMap}; use std::io::Read; use serde_derive::{Deserialize, Serialize}; use snap::read::FrameDecoder; use pueue_lib::log::{get_log_file_handles, read_last_lines}; use pueue_lib::network::message::TaskLogMessage; use pueue_lib::settings::Settings; use pueue_lib::task::Task; /// This ...
true
c453d2e23a7e498d5eaf31a3b45bef904dacb863
Rust
gil0mendes/advent-of-code
/2018/day1/part_1/src/main.rs
UTF-8
195
2.625
3
[]
no_license
const PUZZLE: &str = include_str!("input.txt"); fn main() { let frequency: i32 = PUZZLE.lines().filter_map(|v| v.parse::<i32>().ok()).sum(); println!("Final frequency {}", frequency); }
true
c271a97cfa2964e5f049a3918a4579b0a29a700f
Rust
nmoutschen/orcs
/src/utils.rs
UTF-8
1,939
3.546875
4
[]
permissive
use crate::{Error, Result}; use serde::de::DeserializeOwned; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; /// Load a TOML file into the given structure and return an appropriate error /// if the file cannot be loaded. pub fn load_config<P, T>(path: P) -> Result<T> where P: Into<PathBuf>, ...
true
f34a7f802ec07aa9bf83e3d4ac26c3ec7b7a0df9
Rust
kmyzhang/Assignment6
/main.rs
UTF-8
3,149
3.5
4
[]
no_license
use std::collections::HashMap; use core::borrow::Borrow; use crate as name; //DATA STRUCTURES enum ExprC { NumC { n: f32 }, IdC { s: String }, StringC { s: String }, IfC { cond: Box<ExprC>, thenn: Box<ExprC>, elsee: Box<ExprC> }, LamC { args: Vec<String>, body: Box<ExprC> }, AppC { func: Box<Ex...
true
479fab686a9badf98c1d4b763f07261743d68223
Rust
bjohnnyd/rustynuc
/src/cli.rs
UTF-8
3,570
2.546875
3
[ "MIT" ]
permissive
use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt(rename_all = "kebab-case")] pub(crate) struct RustyNuc { /// Number of threads #[structopt(short, long, default_value = "4")] pub threads: usize, /// Determines verbosity of the processing, can be specified multip...
true
010254b01c266d3185942faf0107f0b9e03690ce
Rust
gky360/rusqly
/src/lib.rs
UTF-8
2,141
2.8125
3
[ "MIT" ]
permissive
#[macro_use] extern crate failure; #[macro_use] extern crate lazy_static; use dirs::home_dir; use rustyline::error::ReadlineError; use rustyline::Editor; use std::path::PathBuf; use std::{fs, io, result}; use structopt::StructOpt; pub type Result<T> = result::Result<T, Error>; #[derive(Fail, Debug)] pub enum Error {...
true
036d4c67ddd8ed407169c0934237f23c80bff1af
Rust
shigedangao/lymui
/lymui/src/generator/tint.rs
UTF-8
2,480
3.34375
3
[ "MIT" ]
permissive
use super::GeneratorOps; use crate::error::Error; use crate::rgb::Rgb; use crate::util::AsFloat; #[cfg(feature = "js")] use crate::js::prelude::*; /// Tint implement the computation of a Tint value from an RGB color /// The tint is computed based on a factor. The factor should be a number between 0 to 1 /// /// Compu...
true
6eea62d592636162027521f6565d95f5566d4034
Rust
BooleanCat/prefab
/src/bin/prefab/config/windows/resources/memory.rs
UTF-8
1,044
3.4375
3
[]
no_license
use serde_derive::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug, PartialEq, Default)] pub struct Memory { #[serde(skip_serializing_if = "Option::is_none")] limit: Option<u64>, } #[cfg(test)] mod tests { use super::Memory; use serde_json; #[test] fn serialize_memory() { ...
true
3f3a58769a920de3917e02186d63882fd16b6afe
Rust
shmishtopher/DailyCode
/problem_006/src/main.rs
UTF-8
2,637
3.640625
4
[ "MIT" ]
permissive
// @author Shmish "shmish90@gmail.com" // @legal MIT "(c) Christopher K. Schmitt" //! # Problem 006 //! //! This problem was asked by Google. //! //! An XOR linked list is a more memory efficient doubly linked list. Instead //! of each node holding next and prev fields, it holds a field named both, //! wh...
true
f348977ab0a3f61fad857800e792ed04730ba9fc
Rust
joonazan/sampled-fractal
/src/main.rs
UTF-8
1,780
2.703125
3
[]
no_license
#[macro_use] extern crate glium; extern crate rand; fn main() { use glium::{DisplayBuild, Surface}; let display = glium::glutin::WindowBuilder::new() .with_dimensions(500, 500) .build_glium().unwrap(); let data: Vec<u8> = (0..512*512*4) .map(|_| rand::random()).collect(); let raw_img = glium::texture::R...
true
45e287cc25c0ea1dfcc49b377c05b63131235d1a
Rust
ori155/hashcode_local
/hashcode_score_calc/src/qual2016/mod.rs
UTF-8
18,723
2.796875
3
[]
no_license
mod parsing; mod error; use error::Qual2016ScoringError; use crate::{ScoringError, InputFileName, Score}; type Row = u16; type Col = u16; type Turn = u32; type WarehouseID = u16; type DroneID = u16; type Weight = u16; type ProductID = u16; type OrderID = u16; type CommandNumber = u64; // DroneID X Turn type Warehous...
true
e41df517ede768c49363a24c0fe96a9a84eec63e
Rust
DowdSean/observatory-new
/src/users/handlers.rs
UTF-8
7,239
2.6875
3
[ "MIT" ]
permissive
//! use diesel::prelude::*; use diesel::{delete, update}; use rocket::http::Status; use rocket::request::Form; use rocket::response::Redirect; use rocket_contrib::json::Json; use crate::auth::crypto::*; use crate::guards::*; use crate::ObservDbConn; use super::models::*; use super::templates::*; #[get("/users/<h>"...
true
4e363d44dc4e5937f6e436c717124379fbe51b53
Rust
iCodeIN/zbus
/zbus_names/src/error.rs
UTF-8
3,039
3
3
[ "MIT" ]
permissive
use static_assertions::assert_impl_all; use std::{convert::Infallible, error, fmt}; use zvariant::Error as VariantError; /// The error type for `zbus_names`. /// /// The various errors that can be reported by this crate. #[derive(Debug)] #[allow(clippy::upper_case_acronyms)] #[non_exhaustive] pub enum Error { Vari...
true
2355089d20b85d402efa18aad049e4ca51fb8094
Rust
harpsword/tex-rs
/src/tex_the_program/section_0586.rs
UTF-8
3,546
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
//! @ ` ` #[derive(Copy, Clone, PartialEq)] pub(crate) struct dvi_command(u8); impl dvi_command { pub(crate) fn byte(self) -> u8 { self.0 } } // @d set_char_0=0 {typeset character 0 and move right} /// typeset character 0 and move right pub(crate) const set_char_0: dvi_command = dvi_command(0); // @d...
true
336beca779efb243c90ba1fd8ca62f1483fb865f
Rust
ajalab/fm-index
/src/util.rs
UTF-8
442
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
pub fn log2(x: u64) -> u64 { ((std::mem::size_of::<u64>() * 8) as u64) - u64::from(x.leading_zeros()) - 1 } #[cfg(test)] mod tests { use super::*; #[test] fn test_log2() { assert_eq!(log2(2u64), 1); assert_eq!(log2(3u64), 1); assert_eq!(log2(4u64), 2); assert_eq!(log2(5u...
true
73473afdb100498f58fdd5a71ef8fcdef6e41e95
Rust
zscaiosi/dprint
/crates/dprint-plugin-typescript/src/plugin.rs
UTF-8
2,372
2.734375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use dprint_core::configuration::{ConfigurationDiagnostic, ResolveConfigurationResult, GlobalConfiguration}; use std::path::PathBuf; use dprint_core::plugins::*; use super::configuration::{Configuration, resolve_config}; use super::formatter::Formatter; /// TypeScript Dprint CLI Plugin. p...
true
e53bdc70ae7d4b5f6856cf64348cea6d49805cbc
Rust
barisu/competitive-programming-rust
/src/data_structures/union_find.rs
UTF-8
1,694
3.65625
4
[]
no_license
pub struct UnionFind { parents : Vec<usize>, size: Vec<usize>, } impl UnionFind { pub fn new(n:usize) -> UnionFind { UnionFind { parents: (0..n).map(|i| i).collect::<Vec<usize>>(), size: vec![1;n] } } pub fn unite( &mut self ,a :usize ,b : usize) { l...
true
e143d6075c9cb90fd5e4acadea9f1d7aa473f9f3
Rust
csos95/cursive-markup-rs
/src/lib.rs
UTF-8
18,906
3.296875
3
[ "MIT", "CC0-1.0", "Apache-2.0" ]
permissive
// SPDX-FileCopyrightText: 2020 Robin Krahl <robin.krahl@ireas.org> // SPDX-License-Identifier: Apache-2.0 or MIT //! `cursive-markup` provides the [`MarkupView`][] for [`cursive`][] that can render HTML or other //! markup. //! //! # Quickstart //! //! To render an HTML document, create a [`MarkupView`][] with the [`...
true
d7f2cf138a3d0240b882818a91275d3e4400f3fe
Rust
tenyoung795/sousveillance-server
/src/server.rs
UTF-8
6,883
2.65625
3
[]
no_license
use std::collections::HashMap; use std::error; use std::fmt; use std::fmt::{Display, Formatter}; use {Stream, Message}; #[derive(Debug)] pub enum AuthError<E> { InvalidToken, Other(E), } impl<E> From<E> for AuthError<E> { fn from(e: E) -> Self { AuthError::Other(e) } } impl<E: Display> Displ...
true
c6716d5ef1e4e33fc8f1ab7294d75cb4dbae40ed
Rust
Voultapher/minijinja
/minijinja/src/compiler.rs
UTF-8
18,449
2.921875
3
[ "Apache-2.0" ]
permissive
use std::collections::BTreeMap; use crate::ast; use crate::error::Error; use crate::instructions::{Instruction, Instructions}; use crate::tokens::Span; use crate::utils::matches; use crate::value::Value; /// Represents an open block of code that does not yet have updated /// jump targets. #[derive(Debug)] enum Pendin...
true
7841d608c3ddae00aaa54a0c16ad84d9023562f6
Rust
id-ilych/hello-rocket
/src/utils/twitter.rs
UTF-8
1,595
3.09375
3
[]
no_license
use super::encode_param; pub fn construct_twitter_url(options: &str) -> String { if options == "" { String::from("https://twitter.com") } else if &options[..1] == "@" { construct_twitter_profile_url(&options[1..]) } else { construct_twitter_search_url(options) } } pub fn constr...
true
ebc1b83c72aa2839b82bd3e00ffc067895d57c9c
Rust
antcrespo/aoc2020
/src/bin/day9.rs
UTF-8
2,075
3.609375
4
[]
no_license
use std::fs; use std::collections::HashSet; fn main() { let input = fs::read_to_string("./src/input/day9.txt") .expect("Something went wrong reading the file"); let mut numbers = Vec::new(); for line in input.split("\r\n") { // println!("{}", line); let value = line.par...
true
c8898ed19df4cc09dd24129f09b3fea40c47a09e
Rust
nyantec/udp-benchmark
/packet/src/lib.rs
UTF-8
1,146
2.84375
3
[]
no_license
use pnet_macros::packet; use pnet_macros_support::types::u64be; //#[derive(Packet)] #[packet] pub struct UdpEcho { // Generic identifier, should be different for every client pub identifier: u64be, // Sequnce nuber, only meaningfull for each client pub sequence: u64be, // Currently unused, open f...
true
9f9886b1a98f5efb8bc8fa573f2972dd8a48fa33
Rust
rust-random/rand
/rand_distr/tests/value_stability.rs
UTF-8
11,787
2.765625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2018 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed /...
true