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
769536f9803fab7c6b2d9e431e628492c6b1ccf1
Rust
sinato/inkwell-playground
/examples/single_number.rs
UTF-8
1,278
2.578125
3
[]
no_license
extern crate inkwell; use inkwell::context::Context; use std::{path, process}; fn compile(code: String) { // initialize let context = Context::create(); let module = context.create_module("my_module"); let builder = context.create_builder(); // generate function prototype let function = modul...
true
65f36a1fb6e7d2d7dbd622f861d2eb25c748d163
Rust
zmilan/examples-1
/sqlx_todo/src/todo/model.rs
UTF-8
3,711
3
3
[ "Apache-2.0" ]
permissive
use serde::{Serialize, Deserialize}; use actix_web::{HttpResponse, HttpRequest, Responder, Error}; use futures::future::{ready, Ready}; use sqlx::{PgPool, FromRow, Row}; use sqlx::postgres::PgRow; use anyhow::Result; // this struct will use to receive user input #[derive(Serialize, Deserialize)] pub struct TodoRequest...
true
07634b517f91ec377957d26b195a2586f7f6b5e4
Rust
cepalle/gomoku-rs
/src/main.rs
UTF-8
1,733
2.875
3
[]
no_license
extern crate cursive; mod game_view; use cursive::Cursive; use cursive::views::{Button, Dialog, LinearLayout, Panel}; use game_view::{GameMode, GameView}; use crate::game_view::Player; fn display_game(siv: &mut Cursive, game_mode: GameMode) { siv.add_layer( Dialog::new() .title("Gomoku") ...
true
3b05136602055bdd6ea7da995fcd88e1c0b7b06c
Rust
hoangpq/scooby
/src/postgres/queries/insert_into.rs
UTF-8
13,025
3.828125
4
[]
no_license
mod values; use std::fmt::{self, Display, Formatter}; use itertools::Itertools; use crate::postgres::general::{Column, Expression, OutputExpression, TableName, WithClause}; use crate::tools::{IntoIteratorOfSameType, IntoNonZeroArray}; pub use values::{DefaultValues, Values, WithColumns, WithoutColumns}; /// Start ...
true
733c5be6e6c59af2d2ff3aa94dfa3e172cc5bb08
Rust
sbstp/merovingian_legacy
/src/input.rs
UTF-8
1,360
3.328125
3
[]
no_license
use std::io::{stdin, stdout, Write}; use std::path::{Path, PathBuf}; macro_rules! print_flush { ($($arg: tt)*) => { let stdout = stdout(); let mut lock = stdout.lock(); let _ = write!(lock, $($arg)*); let _ = lock.flush(); } } // macro_rules! println_flush { // () => (print...
true
b7e4ada162ce87b240dc5e6ee7c6e7f347411e3e
Rust
JackWFinlay/advent_of_code_2020
/day_01/report_repair/src/main.rs
UTF-8
1,632
3.375
3
[]
no_license
mod input; use std::collections::HashMap; fn main() { let data = input::get_input(); let target = 2020u32; let two_sum_product_ans = two_sum_product(data, target); println!("two sum product ans = {}", two_sum_product_ans); let three_sum_product_ans = three_sum_product(data, target); print...
true
8342a4f639abd5d0e19c9f367682715f98131a17
Rust
zxk7516/exercism-rust
/roman-numerals/src/lib.rs
UTF-8
1,362
3.5625
4
[]
no_license
use std::string::ToString; pub struct Roman{ s: String } impl Roman { pub fn from(n: u32) -> Self{ let mut s = String::new(); let m = n / 1000; let c = (n % 1000) / 100; let x = (n % 100) / 10; let i = n % 10; s.push_str( &("M".repeat(m as usize)) ); ...
true
a4bf9f7274688df05313a7a730f4589c8d618e61
Rust
Bruflot/xscreen-rs
/xlib/src/image.rs
UTF-8
2,222
2.6875
3
[ "MIT" ]
permissive
// XCreateImage, XDestroyImage, XGetImage, XGetSubImage // XInitImage, XPutImage, XSubImage(?) use crate::{Display, Window, XImage}; use std::{mem, slice}; use x11::xlib; pub struct Image { inner: XImage, width: u32, height: u32, } impl Image { pub fn get_image( display: &Display, wind...
true
93677939186859330fb9b33506e2ea47f9d3045b
Rust
l4l/radeco-lib
/src/middle/ir.rs
UTF-8
4,953
2.921875
3
[ "BSD-3-Clause" ]
permissive
// Copyright (c) 2015, The Radare Project. All rights reserved. // See the COPYING file at the top-level directory of this distribution. // Licensed under the BSD 3-Clause License: // <http://opensource.org/licenses/BSD-3-Clause> // This file may not be copied, modified, or distributed // except according to those term...
true
ab841e7c2acfc4acb8c1da7d937d74cc79d922bc
Rust
inda20plusplus/gestsson-compiler
/g2bfint/src/main.rs
UTF-8
5,041
3.078125
3
[]
no_license
extern crate getch; use getch::*; const MEM_WIDTH : usize = 128; const MEM_HEIGHT : usize = 128; use std::ops; use std::collections::HashMap; fn main() { let mut program : Vec<Vec<char>> = Vec::new(); let lines = lines_from_file("./program.txt"); for line in lines { let mut crow = Vec::new...
true
21cb0957be172c74c0797e49d50983d958c33777
Rust
DoubleNinthLu/Rust
/mastering_rust_v2/Chapter04/dyn_traits/src/main.rs
UTF-8
157
3.1875
3
[]
no_license
fn main() { let a: &str = "Hello trait object"; show_me(&a); } use std::fmt::Display; fn show_me(item: &dyn Display) { println!("{}", item); }
true
a35ef620d4de4c5853b156bc29944076a4ee00da
Rust
cielavenir/paiza_solutions
/poh2/poh2.rs
UTF-8
1,770
2.796875
3
[]
no_license
fn getline() -> String{ let mut __ret=String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn main(){ let b0=getline(); let b:Vec<_>=b0.trim().split(' ').collect(); let h:i32=b[0].parse().unwrap(); let w:i32=b[1].parse().unwrap(); // https://stackoverflow.com/questions/13212212/creating...
true
9737ef1d547c7057b453e9f631e4e44507818fc2
Rust
kanerogers/a-quest-for-a-triangle
/src/queue_family_indices.rs
UTF-8
1,097
2.6875
3
[]
no_license
use ash::{version::InstanceV1_0, vk, Instance}; #[derive(Clone, Debug)] pub struct QueueFamilyIndices { pub graphics_family: Option<u32>, pub present_family: Option<u32>, } impl QueueFamilyIndices { pub fn find_queue_families( instance: &Instance, device: vk::PhysicalDevice, ...
true
d73001b64f910f3819d7b2c41d34abe0bd95ab7f
Rust
josfeenstra/cjval-rs
/src/main.rs
UTF-8
2,123
3.296875
3
[]
no_license
use std::{env, fs}; use cityjson_validator; fn main() { let args: Vec<String> = env::args().collect(); let config = Config::from_three(&args).expect("couldn't parse"); // println!("args: {:?}", config); println!("Preparing to test a cityjson..."); run(config); println!("Done, have a nice day!")...
true
d38f0ede10cc5811ad777f0f4823dba35a53c51f
Rust
mikialex/rendiation
/interphaser/src/renderer/pipeline.rs
UTF-8
3,243
2.546875
3
[]
no_license
use shadergraph::*; use webgpu::*; use crate::{renderer::UIGlobalParameter, UIVertex}; pub struct SolidUIPipeline { pub target_format: webgpu::TextureFormat, } impl GraphicsShaderProvider for SolidUIPipeline { fn build( &self, builder: &mut ShaderGraphRenderPipelineBuilder, ) -> Result<(), shadergraph:...
true
ef314e1903e198287cf1144ffa7b69b6d413c86b
Rust
iCodeIN/proc-blocks
/label/src/lib.rs
UTF-8
2,937
3.28125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![no_std] pub mod into_index_macro; pub use into_index_macro::IntoIndex; extern crate alloc; use alloc::{borrow::Cow, vec::Vec}; use core::fmt::Debug; use hotg_rune_proc_blocks::{ProcBlock, Tensor, Transform}; /// A proc block which, when given a set of indices, will return their /// associated labels. /// /// # E...
true
f8bd4e8cb6c7de77c925deee0063bf0e25902eff
Rust
dxenonb/puffin
/puffin_egui/examples/eframe.rs
UTF-8
1,615
2.765625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use eframe::{egui, epi}; fn main() { puffin::set_scopes_on(true); // Remember to call this, or puffin will be disabled! let app = ExampleApp::default(); let options = Default::default(); eframe::run_native(Box::new(app), options); } #[derive(Default)] pub struct ExampleApp { frame_counter: u64, }...
true
813ac42b13fa55dedd9d2e6966ef5bb4ecfa36eb
Rust
Renmusxd/RustQIP
/qip/src/types.rs
UTF-8
623
3.15625
3
[ "MIT" ]
permissive
use num_traits::{Float, NumAssign}; use std::fmt::{Debug, Display}; use std::iter::{Product, Sum}; /// The float precision of the circuit. pub trait Precision: Default + NumAssign + Float + Sum + Send + Sync + Display + Product + Debug { } impl Precision for f64 {} impl Precision for f32 {} /// Order of qubits ...
true
c998f30fa2093733a1ac736df1668714f6d91d6e
Rust
Yizhou150/connector-x
/connectorx/src/transports/dummy_arrow.rs
UTF-8
1,190
2.5625
3
[ "MIT" ]
permissive
use crate::destinations::arrow::ArrowDestination; use crate::dummy_typesystem::DummyTypeSystem; use crate::sources::dummy::DummySource; use crate::typesystem::TypeConversion; use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc}; pub struct DummyArrowTransport; impl_transport!( name = DummyArrowTransport, sys...
true
922ac465ac5c32ef92a1c215a97fb54dc4fb7098
Rust
randomPoison/schematic
/tests/primitives.rs
UTF-8
691
2.734375
3
[]
no_license
use pretty_assertions::assert_eq; use schematic::Schema; macro_rules! describe_primitives { ( $( $prim:ty => $schema:ident, )* ) => { $( assert_eq!(Schema::$schema, schematic::describe::<$prim>()); )* }; } #[test] fn describe_primitives() { describe_primitives! { u8 => ...
true
aa98871dc44040178560e285b873b77098b6f543
Rust
xenowing/wideboi
/src/bit_array.rs
UTF-8
1,897
3.25
3
[]
no_license
use std::mem::size_of; type StorageElement = u32; const STORAGE_ELEMENT_BITS: usize = size_of::<StorageElement>(); pub struct BitArray { len: usize, storage: Vec<StorageElement>, } impl BitArray { pub fn new(len: usize) -> BitArray { BitArray { len, storage: vec![0; (len ...
true
4ca1091547756a8267dfeefd637a1c5d98b4f5d2
Rust
Palkovsky/Nudz-Limak
/src/ast.rs
UTF-8
28,311
2.703125
3
[]
no_license
use super::token::{ Token, BinOp, UnaryOp }; use lexer::Stream; use std::{error, fmt}; #[derive(Debug, PartialEq, Clone)] pub struct ParserError { pub text: String } #[derive(Debug, PartialEq, Clone)] struct SingleTokenExprAST; #[derive(Debug, PartialEq, Clone)] pub struct VoidType...
true
1f3bca9362b2cec4964633b633f5cc6163e605b6
Rust
Danue1/Danuel
/engine/src/environment/tile.rs
UTF-8
365
2.890625
3
[]
no_license
use crate::Id; #[derive(Eq, PartialEq, Hash, Clone, Serialize, Deserialize)] pub struct TileId(Id); impl From<Id> for TileId { fn from(id: Id) -> Self { TileId(id) } } impl From<TileId> for Id { fn from(id: TileId) -> Self { id.0 } } #[derive(Clone, Serialize, Deserialize)] pub struc...
true
c0628726c27f57505511899af60076ddfdc5b671
Rust
errord/weld
/weld/src/util/mod.rs
UTF-8
2,320
3.25
3
[ "BSD-3-Clause" ]
permissive
//! Compiler utilities. //! //! This module contains a number of utilities used throughput the compiler, such as unique symbol //! and ID generators and a module for measuring compile-time performance of various aspects of the //! compiler. use fnv; use crate::ast::ExprKind::*; use crate::ast::*; use std::cmp::max; ...
true
8a2641310c8820f2de8dba625450bfff653d7a09
Rust
sugyan/adventofcode
/2019/rust.old/day13/main.rs
UTF-8
3,160
3.453125
3
[]
no_license
use std::cmp::Ordering; use std::io::stdin; use std::thread::sleep; use std::time::Duration; use utils::IntCode; struct Game { score: i64, screen: Vec<Vec<u8>>, paddle: usize, ball: usize, debug: bool, } impl Game { fn new(out: &Vec<i64>) -> Self { let mut xsize = 0; let mut ys...
true
de71f284690ff6e335781c2fbe2d03c075fe2ec4
Rust
Wandalen/OxiSynth
/src/synth/gen.rs
UTF-8
1,034
2.75
3
[]
permissive
use crate::{oxi, Synth}; pub use oxi::soundfont::generator::GeneratorType; use oxi::OxiError; /** Generator interface */ impl Synth { /** Change the value of a generator. This function allows to control all synthesis parameters in real-time. The changes are additive, i.e. they add up to the existing paramete...
true
e95321e6fe3487c6c7896bb543208fee72cf5c85
Rust
RoyLarson/learn_rust
/rust_hello_world/hello_cargo/src/conditionals.rs
UTF-8
1,389
3.765625
4
[ "MIT" ]
permissive
// stuff about conditionals pub fn run(){ println!("\nIn conditionals.rs"); let mut age:u8=18; // if else if age>=21{ println!{"Bartender: What would you like to drink?"} }else { println!{"Bartender: Sorry you have to leave"} } let mut check_id:bool=false; bartender(ag...
true
90ac9ba5d56954f57f90181940da69fa162e3be8
Rust
BraedonWooding/Todo
/src/todo_list.rs
UTF-8
825
3.1875
3
[ "MIT" ]
permissive
// A simple but efficient todo list structure #[derive(Deserialize)] #[derive(Serialize)] #[derive(Debug, Clone)] pub struct TodoList { pub name: String, #[serde(skip)] pub path: String, pub contents: Vec<TodoItem>, } impl TodoList { pub fn create(name: String, path: String) -> TodoList { ...
true
ae78dfae02e8917aa6e8bc612ec91aff44db49a5
Rust
sKyanfIre/rust
/collection/src/hashmap.rs
UTF-8
1,871
3.859375
4
[]
no_license
use std::collections::HashMap; pub fn use_hashmap() { // 1. create let mut map1 = HashMap::new(); map1.insert(String::from("Blue"),10); map1.insert(String::from("Yellow"),20); let string1 = String::from("pink"); let int1 = 30; map1.insert(string1,int1); // map1.insert(1,2); println!(...
true
151a044d13f42e7ae5ab08d51c73c10f66280c90
Rust
chromium/chromium
/third_party/rust/font_types/v0_3/crate/src/name_id.rs
UTF-8
9,519
3.421875
3
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "BSD-3-Clause" ]
permissive
//! Name Identifiers //! //! Although these are treated as u16s in the spec, we choose to represent them //! as a distinct type. use core::fmt; /// Identifier for an informational string (or name). /// /// A set of predefined identifiers exist for accessing names and other various metadata /// about the font and thos...
true
b017810a87c5abb0654c9c34aa48ed015a0b1c13
Rust
iqlusioninc/sear
/src/uuid.rs
UTF-8
545
2.5625
3
[ "Apache-2.0" ]
permissive
//! UUIDs uniquely identify `sear` archives and function as an input to //! HKDF to produce archive-specific cryptographic keys. pub use uuid::Uuid; use getrandom::getrandom; use uuid::{Builder, Variant, Version}; /// Create a random UUID pub fn new_v4() -> Uuid { // Get 128-bits of randomness from the OS's CSPR...
true
fad7a9bea1cf8e28588cad181cf50e10daaf714e
Rust
ecks/msf-client
/src/core.rs
UTF-8
570
2.5625
3
[]
no_license
use crate::conn::Conn; use crate::common::{Res,RcRef}; use crate::msg::{CmdType,RetType}; use crate::msg::{CoreVerCmd,CoreVerRet}; pub struct CoreManager { conn: RcRef<Conn>, } impl CoreManager { pub fn new(conn: RcRef<Conn>) -> CoreManager { CoreManager { conn } } pub fn version(&mut self...
true
94bbb26bac9aae510df1596bfa166cfbf844ed75
Rust
SolarLiner/mfc-rs
/src/env.rs
UTF-8
2,501
3.140625
3
[]
no_license
use std::collections::HashMap; #[derive(Clone, Debug, Eq, PartialEq)] pub struct FnSignature(pub String, pub usize, pub usize); #[derive(Clone, Debug, Eq, PartialEq)] pub struct Frame { varcount: usize, local_vars: HashMap<String, usize>, } #[derive(Clone, Debug, Eq, PartialEq)] pub struct Env { lbl_coun...
true
c433f25b023347223ae11cccc8a561234e4e41ca
Rust
rmohta/ranagram
/src/main.rs
UTF-8
2,258
3.421875
3
[]
no_license
use std::env; use std::io::prelude::*; //Import BufRead use std::fs::File; use std::io::BufReader; use std::collections::HashMap; use std::path::Path; fn main(){ let path = Path::new("/usr/share/dict/words"); match File::open(&path) { Err(e) => println!("Error opening file: {}", e), Ok(f) => { ...
true
c50d613aa255ecd6a98a4c5d624aa4fb89863e94
Rust
Palash90/ganit
/rust/ganit/src/parser/mod.rs
UTF-8
1,259
3.1875
3
[ "MIT" ]
permissive
use std::string::String; use std::vec::Vec; use crate::parser::token::Token; mod token; pub fn tokenize(input: String) -> Vec<Token> { let chars = input.as_bytes(); let _length = chars.len(); let mut _index: usize = 0; let mut _line_number = 0; let mut _column_number = 0; let mut str_literal_...
true
2e1259110f2fc184d6cd20a04d199c3cab321e53
Rust
quininer/indexed-kv
/src/oneshot.rs
UTF-8
1,521
2.890625
3
[]
no_license
use std::rc::{ Rc, Weak }; use std::pin::Pin; use std::cell::RefCell; use std::task::{ Context, Waker, Poll }; use std::future::Future; pub struct Sender<T>(Weak<RefCell<Inner<T>>>); pub struct Receiver<T>(Rc<RefCell<Inner<T>>>); struct Inner<T> { value: Option<T>, waker: Option<Waker>, } pub fn channel<T>...
true
6b1b1b4d9b5ce102be7ce58be6bef19280559286
Rust
Syntaf/Challenge
/bitmap_ascii/main.rs
UTF-8
1,378
3.59375
4
[]
no_license
/* Hex to 8x8 Bitmap Create a 8x8 picture that represents the value you read in example link: http://www.reddit.com/r/dailyprogrammer/comments/2ao99p/7142014_challenge_171_easy_hex_to_8x8_bitmap/ */ use std::io::File; use std::io::BufferedReader; fn hex_to_bin(c: &str) -> &str{ match c { "0" => " ...
true
aef730594b0854ea21032a1f24c446a5d68bad33
Rust
devmattrick/raytracer
/src/main.rs
UTF-8
4,407
2.609375
3
[]
no_license
mod camera; mod color; mod hittable; mod material; mod math; mod ray; mod vec3; use camera::Camera; use chrono::{DateTime, Utc}; use color::as_ppm; use hittable::{Hittable, HittableVec, Sphere}; use material::{DielectricMaterial, LambertianMaterial, Material, MetalMaterial}; use math::rand_double; use ray::Ray; use st...
true
404633c6071aba1085509f624decbfc0c705fa72
Rust
kildevaeld/value-rs
/value-service/src/func.rs
UTF-8
1,183
2.890625
3
[]
no_license
use dale::IntoOutcome; use futures_core::Future; pub trait Func<T> { type Output; fn call(&self, input: T) -> Self::Output; } impl<F, U> Func<()> for F where F: Fn() -> U, U: Future, U::Output: IntoOutcome<()>, { type Output = U; fn call(&self, _ctx: ()) -> Self::Output { (self)()...
true
31f956dd65d2403d8f82a45a02da90aef8846013
Rust
enizor/advent-of-code-2017
/src/bin/day07.rs
UTF-8
5,219
3.328125
3
[]
no_license
use std::fs::File; use std::io::Read; use std::path::Path; #[derive(Debug)] struct Tower { name: String, weight: usize, childs: Vec<Box<Tower>>, } impl Tower { fn insert(&mut self, t: Tower) { self.childs.push(Box::new(t)); } } impl PartialEq for Tower { fn eq(&self, other: &Tower) ->...
true
3056151daedfb6bda6b82294afa359628e110ecd
Rust
E-Neo/blog-server
/src/views/auth.rs
UTF-8
2,296
2.703125
3
[]
no_license
use crate::error::ServiceError; use crate::models::user::User; use crate::Pool; use actix_identity::Identity; use actix_web::{error::BlockingError, web, HttpResponse}; use diesel::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Deserialize)] pub struct AuthData { pub username: String, pub password: S...
true
99abc22906a03a6aee80d53c26d396c93369597d
Rust
bwestlin/advent-of-code-2020
/rust/src/day05.rs
UTF-8
2,466
3.328125
3
[ "MIT" ]
permissive
extern crate utils; use std::env; use std::collections::BTreeSet; use std::ops::RangeInclusive; use std::io::{self, BufReader}; use std::io::prelude::*; use std::fs::File; use utils::*; type Seat = String; type Input = Vec<Seat>; fn bsp_to_val(s: &str, l_chr: char, h_chr: char, mut range: RangeInclusive<usize>) -> ...
true
4657d19f46d5d9a7d2be828c8ec88574468d6c07
Rust
sbstp/merovingian_legacy
/src/tasks/import.rs
UTF-8
4,896
2.84375
3
[]
no_license
use std::path::{Path, PathBuf}; use database::{Database, Movie, Subtitle}; use fingerprint; use fs::{self, Entry}; use parse; use tmdb::search; use tree::{Node, Tree}; fn build_movie_path( base: &Path, ext: &str, movie: &search::Movie, duplicate_index: i32, ) -> PathBuf { let version = if duplicat...
true
cc37860c349c79aed6d57ffe6aac2c2291f7f928
Rust
enerqi/mazes
/src/_prototyping/gridcell_prototype.rs
UTF-8
1,005
2.921875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::cell::{RefCell}; use std::rc::{Rc}; use cell::Cell; // Rc is a pointer to the value T // Heap allocated T with many readers // . does DeRef automatically, though can manually deref with * // clone is used to pass the ref-counted pointer // but you can take a &T to the value inside, not needing to inc/dec the...
true
04f1c89a91cf38a77b42185b9aa1d2f8a8c99dbd
Rust
RacleRay/Self-build-tools
/AirWarInTerm/src/player.rs
UTF-8
1,704
3.15625
3
[]
no_license
use crate::frame::{Drawable, Frame}; use crate::invaders::Invaders; use crate::bullets::Bullet; use crate::{NUM_ROWS, NUM_COLS}; use std::time::Duration; pub struct Player { x: usize, y: usize, bullets: Vec<Bullet>, } impl Player { pub fn new() -> Self { Self { x: NUM_ROWS / 2, ...
true
32dc4d5b9bb613e3674471cc43c3f92f250c2a09
Rust
PolkaX/rust-statemachine
/src/state_machine.rs
UTF-8
1,567
2.703125
3
[]
no_license
// Copyright 2020 PolkaX use crate::{Event, EventError, EventRet, Handler, Planner}; use shrev::EventChannel; use std::sync::mpsc::{channel, Sender}; use std::thread; const EVENTS_CAPACITY: usize = 20; pub struct StateMachine { sender: Option<Sender<Event>>, } impl Planner for StateMachine { fn plan(&self, ...
true
e66d8482ce33521a0b4e83d8aecf7ddf2d88a374
Rust
JohnTitor/reing
/src/utils.rs
UTF-8
633
2.90625
3
[ "MIT" ]
permissive
use chrono::prelude::*; use chrono::Duration; pub fn recognizable_datetime(datetime: DateTime<Local>) -> String { let now = Local::now(); let duration = now.signed_duration_since(datetime); if duration < Duration::seconds(1) { String::from("今") } else if duration < Duration::minutes(1) { ...
true
4e72ba0ad0fe8a8df91b067a6ae0b5b4f9a42d97
Rust
DiveFish/ambiguity-stats
/src/readers/ngram_graph_reader.rs
UTF-8
4,053
2.515625
3
[]
no_license
extern crate conllx; use conllx::Token; //use petgraph::dot::{Config, Dot}; use petgraph::graph::NodeIndex; use petgraph::visit::EdgeRef; //use petgraph::EdgeDirection; use std::collections::{HashMap, HashSet}; //use {first_matching_edge, to_dot, DependencyGraph, DependencyNode}; use sentence_to_graph; //TODO: Unfini...
true
f16a02df9f8c598bdcf8dbd9b35aa06e089d07ad
Rust
calum/terminal_graphics_api
/src/display/mod.rs
UTF-8
547
3.375
3
[]
no_license
//! Everything required to interact with the terminal. //! //! The Display is used to create a window within the terminal. pub mod colour; pub mod display; pub mod pixel; #[cfg(test)] mod tests { use display::colour::Colour; use display::display::Display; #[test] fn it_works() { let mut scree...
true
191ed3382ddb6284c5c1dc24e018f34c0a1e453d
Rust
heliumbrain/axum
/examples/tokio-postgres/src/main.rs
UTF-8
3,082
2.875
3
[ "MIT" ]
permissive
//! Run with //! //! ```not_rust //! cargo run -p example-tokio-postgres //! ``` use axum::{ async_trait, extract::{Extension, FromRequest, RequestParts}, handler::get, http::StatusCode, AddExtensionLayer, Router, }; use bb8::{Pool, PooledConnection}; use bb8_postgres::PostgresConnectionManager; us...
true
355036aee55b1e6fcac01551ab68abb2c355845e
Rust
saltlick-crypto/saltlick-cli
/src/cli.rs
UTF-8
4,876
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
// Copyright (c) 2020, Nick Stevens <nick@bitcurry.com> // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/license/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distribute...
true
29e6d8c397382354527a58a82265c31b1f963bc8
Rust
tekul/mina
/src/ui.rs
UTF-8
3,203
2.84375
3
[]
no_license
use crate::app::App; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Modifier, Style}, text::{Span, Spans}, widgets::{Block, Borders, Clear, List, ListItem, Paragraph, Row, Table}, Frame, }; pub fn draw<B: Backend>(f: &mut Frame<B>, app: &mut App) { let ...
true
ec360e788e67665ea1e8635230fe09d224caed39
Rust
cetusDownfall/exercises
/exercises/rust-exercises/b_tree/src/tree.rs
UTF-8
2,055
3.34375
3
[]
no_license
use std::rc::*; use std::cell::RefCell; use std::cmp::PartialOrd; pub struct Node<T: PartialOrd> { conts: Box<T>, children: [RefCell<Option<Rc<Node<T>>>>; 2], parent: RefCell<Option<Weak<Node<T>>>> } impl<T: PartialOrd> Node<T> { pub fn new(conts: T) -> Node<T> { Node { conts: Box::n...
true
11d40c11dd2b4bb4db0f4b41ef18c6bffe28ea96
Rust
ST92/secondary-control-keyboard
/src/inputs.rs
UTF-8
2,207
3.265625
3
[]
no_license
use evdev::{self, Device, InputEvent, InputEventKind, Key}; /// /// Pick out the secondary keyboard (as opposed to a main keyboard) from the /// xinput device list. /// pub(crate) fn get_keyboard() -> Device { let mut keyboard: Vec<Device> = evdev::enumerate() .filter(|dev| dev.name().unwrap_or_defau...
true
9532be2c2cbb0f7e55cd1a4dab98cf87aa947c7f
Rust
abonander/rust-sdl2
/src/sdl2/touch.rs
UTF-8
1,269
2.578125
3
[ "MIT" ]
permissive
use std::ptr; pub type TouchDevice = ll::SDL_TouchID; #[deriving(PartialEq, Copy)] #[repr(C)] pub struct Finger { id: TouchDevice, x: f32, y: f32, pressure: f32, } #[allow(non_camel_case_types)] pub mod ll { use libc::{c_int, int64_t}; use touch::Finger; pub type SDL_TouchID = int64_t; ...
true
58ae3ef81e74ba9549f25638292a6f487efbfc27
Rust
g2xpf/ecs-rs
/src/lib/data_types/cached_vec.rs
UTF-8
2,626
3.1875
3
[]
no_license
use super::stack::Stack; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::ops::{Deref, DerefMut}; #[derive(Debug)] pub struct CachedVec<T> { key_max: usize, key_garbage: Stack<usize>, data: HashMap<usize, T>, } impl<T> CachedVec<T> where T: Default, { #[inline] pu...
true
4b7cfb113221b36e368ce56a3ed4e82f3f842e68
Rust
gen0083/atcoder_python
/rust/abc213/src/bin/d.rs
UTF-8
1,085
2.796875
3
[]
no_license
use std::{ cmp::Reverse, collections::{BinaryHeap, HashSet}, }; use itertools::Itertools; use proconio::input; fn main() { input! { n: usize, roads: [(usize, usize); n - 1] } let mut nodes: Vec<BinaryHeap<_>> = vec![BinaryHeap::new(); n]; for (a, b) in roads { nodes[a -...
true
92499a63e3cc1e2bc306c29bd035c0c95db899c3
Rust
cameron-williams/zkru
/src/main.rs
UTF-8
8,151
3.15625
3
[]
no_license
#[macro_use] extern crate lazy_static; extern crate clap; use clap::{Arg, App}; use regex::Regex; use std::io::prelude::*; use std::io::Error; use std::path::{Path, PathBuf}; use std::fs::{self, create_dir}; lazy_static! { // HTML patterns, sort these by priority as they will be find/replace within the body ...
true
439c3188b4ae741527af3a2cf63e7fd6fe60706b
Rust
csivitu/pls.give
/src/commands/witeboard.rs
UTF-8
473
2.53125
3
[ "MIT" ]
permissive
use serenity::framework::standard::{macros::command, CommandResult}; use serenity::model::prelude::*; use serenity::prelude::*; use uuid::Uuid; #[command] #[description = "Whiteboard"] #[description = "gives link to whiteboard"] #[description = "Usage: pls.give board"] pub async fn board(ctx: &Context, msg: &Message) ...
true
cc510056501fb2433de1ed922b6ec8df7171bb7d
Rust
dwaypro/rust
/structsenums/enums/enums/src/main.rs
UTF-8
1,807
3.671875
4
[]
no_license
// use std::option::Option; enum IpAddrKind{ V4(u8, u8, u8, u8), V6(String), } #[derive(Debug)] enum UsState{ Alabama, Alaska } enum Coin{ Penny, Nickel, Dime, Quarter(UsState), } // enum Option<T> { // Some(T), // None, // } fn route(ip_type: IpAddrKind){ } fn value_in_...
true
e84431d99a29ec897a2d4b01ac3aecd0acb965dd
Rust
another-s347/rusty-p4
/rusty-p4/src/app/graph.rs
UTF-8
11,502
2.890625
3
[ "Apache-2.0" ]
permissive
use crate::app::common::MergeResult; use crate::representation::{ConnectPoint, Device, DeviceID, DeviceType, Link}; use std::cmp::Ordering; use std::collections::{BinaryHeap, HashMap, HashSet}; use std::fmt::Formatter; use std::fmt::{Debug, Display}; use std::hash::Hash; // index = x+y*n pub struct GraphBase<T> { ...
true
49ca563a2377291a1ca62eca52fb73001785725b
Rust
2lx/luafmt
/src/formatting/test/table.rs
UTF-8
5,709
2.8125
3
[ "MIT" ]
permissive
use super::common::*; use crate::config::*; #[test] fn test_table_iv_oneline() { let cfg = Config { fmt: FormatOpts { hint_table_constructor: Some(" ".to_string()), replace_zero_spaces_with_hint: Some(true), remove_spaces_between_tokens: Some(true), remove_si...
true
da936b25dae0547cd1bd9bd729af09ec8e7e7db3
Rust
ovanwijk/iota.rs
/iota-client/core/get_neighbors.rs
UTF-8
1,153
2.703125
3
[ "MIT" ]
permissive
use iota_model::Neighbor; use reqwest::r#async::{Client, Response}; use reqwest::Error; use tokio::prelude::Future; /// Returns the set of neighbors you are connected with, as /// well as their activity count. The activity counter is reset /// after restarting IRI. pub fn get_neighbors( client: &Client, uri: &...
true
e38601b158b1f86c166c75abf96d9808967025a4
Rust
w3f-grants-archive/starry_node
/pallets/pallet-nft/src/lib.rs
UTF-8
23,014
2.953125
3
[ "Unlicense", "Apache-2.0" ]
permissive
//! # NFT Module //! //! - [`Config`] //! - [`Call`] //! //! Create a batch of NonFungible or Fungible Tokens. //! //! ### Terminology //! //! * **Mint:** Mint one or a batch of NFTs or some FTs (SemiFts) //! * **transfer:** Transfer one or a batch of tokens from one account to another account //! * **Burn:** Destro...
true
13dee964c82abfe52579530f9b663ec25f6f6923
Rust
dondreytaylor/azul
/azul/src/daemon.rs
UTF-8
6,190
3.1875
3
[ "MIT" ]
permissive
use std::{ sync::atomic::{AtomicUsize, Ordering}, time::{Duration, Instant}, fmt, hash::{Hash, Hasher}, }; use { dom::{UpdateScreen, DontRedraw}, app_resources::AppResources, }; /// Should a daemon terminate or not - used to remove active daemons #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub...
true
fa95e26b3672f2fe295ca4e2fdbaac2cd5dec538
Rust
sporto/euler-problems
/e0004-largest-palindrome-product/src/main.rs
UTF-8
383
3.21875
3
[]
no_license
fn main() { let mut pals = vec![]; for a in (500..=999).rev() { for b in (a..=999).rev() { let mul = a * b; if as_string(mul) == as_string_reversed(mul) { pals.push(mul); } } } println!("{:?}", pals.iter().max()); } fn as_string(n: u32) -> String { format!("{}", n) } fn as_string_reversed(n: u32...
true
2d59a1f3a1d7c0341f40f67d2eb34eab09af3575
Rust
sunakan/notes-about-rust
/atcoder/ABC086C-Traveling/src/main.rs
UTF-8
2,198
3.53125
4
[]
no_license
struct Point { x: i64, y: i64, } struct Plan { time: i64, point: Point, } fn main() { let n = read(); let mut plans = Vec::with_capacity(n); for _ in 0..n { let txy = read_vec(); let plan = Plan { time: txy[0], point: Point { x: txy[1]...
true
59fd787a5cbddd9fd201b663bdb79299e288d71b
Rust
vtavernier/tinygl
/tinygl-compiler/src/compiler/wrapped_program.rs
UTF-8
884
2.6875
3
[ "MIT" ]
permissive
use heck::CamelCase; use super::wrapped_shader::*; pub struct WrappedProgram<'s> { struct_name: String, attached_shaders: Vec<&'s dyn WrappedShaderDetails>, } impl<'s> WrappedProgram<'s> { pub fn new(program_name: &str, attached_shaders: &[&'s dyn WrappedShaderDetails]) -> Self { let struct_name ...
true
59fa8019d938ed0d77eedf98de473fbef9b6d807
Rust
toba/osm-models-rs
/src/relation.rs
UTF-8
4,102
3.296875
3
[]
no_license
use crate::{node::Node, tag::Tagged, ElementID, TagMap, Timestamp}; use serde::Deserialize; /// Relation member entry may refer to a single `Node` or a `Way` of nodes #[derive(Default, Deserialize)] pub struct Member<'a> { pub nodes: Vec<&'a Node>, /// https://wiki.openstreetmap.org/wiki/Relation#Roles pub...
true
e67ccdc0d6a2aa5e73420c52356757042b2260f9
Rust
Pauan/seed
/src/shortcuts.rs
UTF-8
29,758
3.0625
3
[ "MIT" ]
permissive
//! This file exports helper macros for element creation, populated by a higher-level macro, //! and macros for creating the parts of elements. (attrs, style, events) /// Create macros exposed to the package that allow shortcuts for Dom elements. /// In the matching mattern below, we match the name we want to use with...
true
84ca98d5af4d820305fba606806ece39bd0515e8
Rust
willi-kappler/green_moon
/tests/test_vector2d.rs
UTF-8
999
3.15625
3
[ "MIT" ]
permissive
extern crate green_moon; use green_moon::Vector2D; #[test] fn test_add() { let a = Vector2D { x: 0.5, y: 1.2 }; let b = Vector2D { x: 1.5, y: 0.8 }; assert_eq!(a + b, Vector2D { x: 2.0, y: 2.0 }); } #[test] fn test_add_assign() { let mut a = Vector2D { x: -1.0, y: 6.0 }; let b = Vector2D { x: 1....
true
07ac5a6419ed5059659144de2318ee981ded4090
Rust
michalbe/rust-raytracer
/src/material.rs
UTF-8
3,473
3.015625
3
[]
no_license
use crate::{ hitable::HitRecord, ray::Ray, utils::{ random_in_unit_sphere, reflect, refract, schlick, }, }; use vec3D::Vec3D; pub trait Scatter { fn scatter(&self, ray_in: &Ray, rec: &HitRecord, attenuation: &mut Vec3D, scattered: &mut Ray) -> bool; } #[derive(Clon...
true
1c07ae0a31aed44f3378da541bb3803281b70980
Rust
trescommas/crypto-crawler-rs
/crypto-ws-client/src/clients/utils.rs
UTF-8
3,745
2.796875
3
[ "Apache-2.0" ]
permissive
use http::Uri; use log::*; use native_tls::{HandshakeError as TlsHandshakeError, TlsConnector}; use std::{ net::{SocketAddr, TcpStream, ToSocketAddrs}, thread, time::{self, Duration}, }; use tungstenite::{ client::{self, AutoStream, IntoClientRequest}, handshake::{client::Response, HandshakeError}, ...
true
f650c41c892006c379275f8090010f6dcaa862d0
Rust
mendess/LI3_as_a_service
/src/parse.rs
UTF-8
1,622
2.890625
3
[]
no_license
use crate::store::{ client::Client, product::Product, sale::{Filial, Sale}, Store, }; use std::{ convert::TryFrom, fs::File, io::{BufRead, BufReader, Error, ErrorKind, Result}, }; pub fn load_products(file: &str, store: &mut Store) -> Result<()> { let file = BufReader::new(File::open(fi...
true
8dae3f3e7b6ce520fcb101aea577c93b38fa5e44
Rust
saibatizoku/herder
/examples/create-app.rs
UTF-8
3,435
2.8125
3
[ "MIT" ]
permissive
#![recursion_limit = "1024"] extern crate clap; extern crate herder; extern crate serde_json; use clap::{Arg, App}; use herder::Mastodon; use herder::errors::*; use herder::mastodon::NodeInstance; use herder::api::oauth::{CreateApp, OAuthApp}; use std::fs::File; fn main() { if let Err(ref e) = run() { pr...
true
63e43ebf58a804758f8d9eb13f19b1874a4185b4
Rust
starcoinorg/starcoin
/config/src/api_quota.rs
UTF-8
2,321
3.15625
3
[ "Apache-2.0" ]
permissive
use anyhow::{bail, Result}; use serde::de::Error; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::num::NonZeroU32; use std::str::FromStr; #[derive(Debug, Clone, PartialEq, Eq)] pub struct ApiQuotaConfig { pub max_burst: NonZeroU32, pub duration: QuotaDuration, } impl std::fmt::Display f...
true
d47dd91b6f3588e7b18b6245c2c6a913a78a472f
Rust
SyedIbtahajAhmed/Rust-Advanced
/Structures In Rust/src/main.rs
UTF-8
842
3.96875
4
[]
no_license
//Three Stages //Development //Debug //Production //Defining Struct #[derive(Debug)] struct Car{ engine: i32, seats: i32, name: String, } //Implementing Struct impl Car{ //Associated Function fn asso_car(engine: i32, seats: i32, name: String) -> Car{ Car{ engine: engine, ...
true
c19ce78eead5200d8b1aedaf698b4772e739126f
Rust
dayn9t/rx
/rx/src/algo/slice.rs
UTF-8
405
3.078125
3
[ "Apache-2.0" ]
permissive
/// 获取new中与old中不同元素的下标集合 pub fn diff<T: Eq>(new: &[T], old: &[T]) -> Vec<usize> { let mut vec = Vec::new(); let len = new.len().min(old.len()); for i in 0..len { let a = new.get(i).unwrap(); let b = old.get(i).unwrap(); if a != b { vec.push(i) }; } for i ...
true
da820a481dabb38f4c30d1f1aa9f401c9710160d
Rust
nickolay/git-interactive-rebase-tool
/src/todo_file/src/action.rs
UTF-8
5,788
2.921875
3
[ "BSD-3-Clause", "GPL-3.0-only", "Apache-2.0", "BSD-2-Clause", "GPL-3.0-or-later", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later" ]
permissive
use std::fmt::{Display, Formatter}; use crate::errors::ParseError; /// Describes an rebase action. #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[allow(clippy::exhaustive_enums)] pub enum Action { /// A break action. Break, /// A drop action. Drop, /// An edit action. Edit, /// An exec action. Exec, /// A fi...
true
8f861c7c7a55c31393057dd499df3b29cdb1c4e2
Rust
NovaDenizen/red_primality
/src/lib.rs
UTF-8
1,094
3.53125
4
[]
no_license
//! red_primality provides zero-setup primality testing and factoring for all u64 //! //! # Example //! //! ``` //! use red_primality::{ is_u64_prime, factor, Prime, euler_totient, mobius }; //! //! fn main() { //! // Primality testing //! assert!(is_u64_prime(5)); //! assert!(!is_u64_prime(6)); //! //! ...
true
1583f3aec6d7daf57c5a97aae34407fdf4515820
Rust
moshg/rust-std-ja
/src/test/run-pass/issue-36381.rs
UTF-8
1,003
2.546875
3
[ "MIT", "BSD-3-Clause", "NCSA", "Apache-2.0", "LicenseRef-scancode-other-permissive", "BSD-2-Clause" ]
permissive
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
true
65c39f1ca16fd30a8197eb6e56b73ac93a88f734
Rust
chmod222/AdventOfCode-2018
/Rust/day17/src/main.rs
UTF-8
10,476
2.859375
3
[]
no_license
use shared::{ grid::{self as sg, Grid, GridTile, Coordinate}, input::read_stdin_lines }; use lazy_static::*; use regex::Regex; #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] enum Tile { Clay, Sand, Spring, Water, WaterAtRest } struct Map { data: Vec<Vec<Tile>>, xstart: usize } im...
true
bed4599955af7061e6c1538857a9d92b013b9d3c
Rust
T0mstone/nonempty_vec
/src/lib.rs
UTF-8
12,122
2.9375
3
[]
no_license
use std::borrow::{Borrow, BorrowMut}; use std::io::{self, IoSlice, Write}; use std::iter::FromIterator; use std::num::NonZeroUsize; use std::ops::{Deref, DerefMut, Index, RangeBounds}; use std::slice::SliceIndex; use std::vec::Splice; macro_rules! copy_fn { (@single $v:vis fn $fname:ident(&mut self $(, $arg:ident:...
true
9a9d1f23675ea24c60b6b828b4ba5f4a7e9f9835
Rust
Teln0/SysControl
/rust/src/memory/heap/mod.rs
UTF-8
9,554
2.53125
3
[]
no_license
use crate::memory::frame_allocator::{FrameAllocator, FRAME_SIZE}; use crate::memory::paging::{EntryTable, PageInfo, EntryFlags, TableAccess}; use core::alloc::{Layout, GlobalAlloc}; use crate::utils::ceil_div_usize; use spin::Mutex; use core::ops::DerefMut; use crate::HEAP_OFFSET; pub struct AllocOption<T> (pub Option...
true
fe0935c35d003f48084b323372aa9d55b6e1c8b4
Rust
udoprog/ontv
/src/database/seasons.rs
UTF-8
5,103
3.09375
3
[ "Apache-2.0", "MIT" ]
permissive
use core::fmt; use std::collections::HashMap; use std::ops::Deref; use crate::model::{Season, SeasonNumber, SeriesId}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] struct Pointer { series: SeriesId, number: SeasonNumber, } impl Pointer { fn new(series: SeriesId, number: SeasonNumber) -> Self { ...
true
ed1e2a66c9109e059b4383db34602c6276e19ef7
Rust
braincore/pid-rs
/src/lib.rs
UTF-8
17,051
3.90625
4
[ "MIT", "Apache-2.0" ]
permissive
//! A proportional-integral-derivative (PID) controller library. //! //! See [Pid] for the adjustable controller itself, as well as [ControlOutput] for the outputs and weights which you can use after setting up your controller. Follow the complete example below to setup your first controller! //! //! # Example //! //! ...
true
7a0f135a262c06fadec93116a154990649b4de8f
Rust
jievince/nebula-rs
/serde-nebula-fbthrift-graph/src/de/datetime.rs
UTF-8
2,829
2.90625
3
[ "MIT", "Apache-2.0" ]
permissive
pub type Year = i16; pub type Month = i8; pub type Day = i8; pub type Hour = i8; pub type Minute = i8; pub type Second = i8; pub type Millisec = i16; pub type Microsec = i16; use serde::Deserialize; #[derive(Deserialize, PartialEq, Debug)] pub struct Timestamp(pub i64); impl Timestamp { #[cfg(feature = "chrono")...
true
6a211c8fceafe2313e4f57d0342daae766981c16
Rust
bahodge/project_euler
/rust/src/problems/problem_2.rs
UTF-8
854
3.6875
4
[]
no_license
/* Problem #2 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued...
true
fbdd931af4ef212bee9ae9fcac7b1e02f2718dae
Rust
TheHunterDog/ProjectEuler
/rust/problem1/src/main.rs
UTF-8
907
4.03125
4
[]
no_license
fn main() { println!("If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000."); let mut numbers = vec![]; let limit = 1000; let mut sum:i64 = 0; let multiples = [...
true
3e5647d727f4b3e9b50e72c6d3f70c1a3a2a41df
Rust
rustcargo/rustlearn
/exercises/play-normal/src/lib.rs
UTF-8
1,565
3.328125
3
[]
no_license
pub mod anagram; pub mod cache; pub mod ownership; pub mod rstype; /// 方法1 pub fn add_a(a: u32) -> u32 { 100 + a } //rust内存的存储方式有 堆内存 和 栈内存 //栈内存 由编译器或系统自动控制的内存,先进后出速度很快,但是存储的数据大小和生命周期是确定的 //堆内存 是程序运行时动态分配的内存空间,即操作系统或编译器指定的一块够用的动态空间,按需分配,每块空间有各自的地址标注,这个地址就是指针。 //在rust 中是所有权控制堆内存的什么周期的。 //rust所有权规则: // 1 Rust 中的每一...
true
69ea27ff26326e5a1a008a9ddc02fc73e6419518
Rust
isabella232/onefuzz
/src/agent/onefuzz-agent/src/tasks/generic/input_poller/callback.rs
UTF-8
2,440
2.609375
3
[ "MIT", "LicenseRef-scancode-generic-cla" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. use std::path::{Path, PathBuf}; use anyhow::Result; use async_trait::async_trait; use reqwest::Url; use storage_queue::{Message, QueueClient}; #[async_trait] pub trait Queue<M> { async fn pop(&mut self) -> Result<Option<M>>; async fn...
true
3ac0e17f4abcc13ee41aac5990f234455a22717b
Rust
jesusjbr/advent-of-code-2020
/src/day9.rs
UTF-8
2,249
3.421875
3
[]
no_license
use itertools::Itertools; fn parse_input(input: &str) -> Vec<u64> { input .lines() .map(|line| line.parse::<u64>().unwrap()) .collect() } fn check_bad_data(encrypted_data: Vec<u64>, preamble_size: usize) -> u64 { encrypted_data .windows(preamble_size + 1) .find(|window|...
true
36b6ed89b38cf1b2d5666b0440c5627d773fa58d
Rust
Defelo/AdventOfCode
/2022/07.rs
UTF-8
2,539
3.015625
3
[ "MIT" ]
permissive
use rustc_hash::FxHashMap; type Input<'a> = Vec<Node<'a>>; struct Node<'a> { size: u64, parent_id: Option<usize>, names: FxHashMap<&'a str, usize>, visited: bool, } impl<'a> Node<'a> { fn new(parent_id: Option<usize>) -> Self { Self { size: 0, parent_id, ...
true
9c7965560e923481b2d97b583e6ddf1d6bac0e26
Rust
Larusso/unity-version-manager
/commands/uvm-version/src/main.rs
UTF-8
3,870
2.578125
3
[ "Apache-2.0" ]
permissive
use anyhow::Result; use console::style; use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle}; use log::*; use semver::VersionReq; use structopt::{ clap::crate_authors, clap::crate_description, clap::crate_version, clap::AppSettings, StructOpt, }; use uvm_cli; use uvm_cli::{options::ColorOption, set_color...
true
3ab11c8a94389e65620b308a20c2e365dbc28f4b
Rust
tawaren/Sanskrit
/sanskrit_interpreter/src/value_encoding.rs
UTF-8
10,230
2.84375
3
[]
no_license
use model::{ValueSchema, Entry, Adt}; use sanskrit_common::encoding::{Serializer, Serializable, ParserAllocator, Parser, Parsable, VirtualSize}; use sanskrit_common::errors::*; use sanskrit_common::model::SlicePtr; use sanskrit_common::arena::VirtualHeapArena; pub fn parse_with_schema<'c, 'h, 'b>(schema:ValueS...
true
ebfa256946e7f78f746ac9559a32e5964b483b4d
Rust
pettan0818/book_algo_rust
/archived/ABC121B/src/main.rs
UTF-8
514
2.75
3
[]
no_license
use proconio::input; fn main() { input! { n: i32, m: i32, c: i32, b_list: [i32; m], a_list: [[i32; m]; n] } let mut result_list = Vec::new(); for a in a_list { let mut res = 0; for (a_t, b) in a.iter().zip(b_list.iter()) { res = res + a_t * b;...
true
c346619e0debe8c424c5a3077f9722989bfefbe8
Rust
darkhypervisor/rustos-hv
/lib/aarch64/src/cache.rs
UTF-8
2,116
2.71875
3
[]
no_license
/// Align `addr` downwards to the nearest multiple of `align`. /// /// The returned usize is always <= `addr.` /// /// # Panics /// /// Panics if `align` is not a power of 2. fn align_down(addr: usize, align: usize) -> usize { if align == 0 { panic!("align must be a power of two"); } if a...
true
5578fe8946705c67bc29eefcc9b808ddf69dd0e7
Rust
liljencrantz/crush
/src/lang/serialization/struct_serializer.rs
UTF-8
3,326
2.6875
3
[ "MIT" ]
permissive
use super::super::errors::{error, CrushResult}; use super::super::value::Value; use super::model; use super::model::{element, Element}; use super::{DeserializationState, Serializable, SerializationState}; use crate::lang::data::r#struct::Struct; use crate::util::identity_arc::Identity; use std::collections::hash_map::E...
true
7dd7e1d58620fd05c7942b5df14dcefb144aa3ff
Rust
sthomen/rhg
/src/revlog/changeset.rs
UTF-8
2,901
3.078125
3
[]
no_license
extern crate flate2; extern crate datetime; use std::fmt; use std::io::Read; use std::string::String; use datetime::{OffsetDateTime,LocalDateTime,Offset,ISO}; use flate2::bufread::ZlibDecoder; #[derive(Debug)] pub struct Changeset { pub data: Vec<u8>, pub files: Vec<String>, pub hash: Option<String>, pub author: ...
true
19a0419d8569498cd6edd3fd53c48199145f3b1d
Rust
Sakarah/petitrust-tests
/typing/good/zetary-shadow.rs
UTF-8
122
2.765625
3
[]
no_license
fn foo(x:bool) { while x { let x=42; x+1; } if x {} } fn main () { foo(false); }
true