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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
340bd0774484fd98c0015dabffcc77ee798f274b | Rust | Pierre-Colin/rcvs-web | /src/data.rs | UTF-8 | 977 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fmt::Debug;
use std::hash::Hash;
use std::iter::FromIterator;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Clone, Debug)]
pub struct AlternativeData {
pub id: String,
pub description: String,
pub icon: String,
}
#[derive(Serialize, Debug, Clone)]
#[se... | true |
28db292470981bc433a6237bc0b173037e10bc73 | Rust | hdelva/fosite | /rust/fosite/src/core/output/while_loop_change.rs | UTF-8 | 1,616 | 2.59375 | 3 | [] | no_license | use super::Path;
use super::MessageContent;
use term_painter::ToStyle;
use term_painter::Color::*;
use term_painter::Attr::*;
type Sources = HashMap<GastID, (i16, i16)>;
type Nodes = HashMap<GastID, GastNode>;
use std::collections::HashMap;
use super::GastID;
use super::GastNode;
use super::PathID;
use std::hash::... | true |
4315957e2f3a96f41f20fd89fc9cfa6b8cd2a382 | Rust | Roboadam/economy_sim | /src/ai_person.rs | UTF-8 | 1,679 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{components::Position, traits::*};
#[derive(Default)]
pub struct AiPerson {
texture_index: usize,
position: Position,
hunger: f32,
traveling_to: Option<Position>,
}
impl IsDrawable for AiPerson {
fn render_info(&self) -> (usize, &Position) {
(self.texture_index, &self.position)
... | true |
91e90304af8fed53c212375eb90f04ee60809bcf | Rust | cympfh/cympfh.github.io | /procon/bin.count.rs | UTF-8 | 934 | 3.734375 | 4 | [] | no_license | /// Binary Search - Counting Elements in a Sorted Array
// @bin.search.rs
// the number of elements == x
fn binsearch_count<T: Ord>(x: T, xs: &Vec<T>) -> usize {
let n = xs.len();
let i = binsearch(0, n, &|i| xs[i] >= x);
let j = binsearch(0, n, &|i| xs[i] > x);
j - i
}
// the number of elements >= x
f... | true |
4660efe25477a145c40b822292c6741573f9fc6f | Rust | Ayush1325/media_infer | /tests/integration_test.rs | UTF-8 | 3,078 | 2.515625 | 3 | [
"MIT"
] | permissive | use media_infer::ContainerType;
#[test]
fn test_empty() {
let t1 = ContainerType::from_bytes(&[]);
assert!(t1.is_err());
}
#[test]
fn test_garbage() {
let t = ContainerType::from_bytes(&[0; 1024 * 1024]);
assert!(t.is_err());
}
#[test]
fn test_asf_bytes() {
let buffer = [0x30, 0x26, 0xb2, 0x75, 0... | true |
2ebe5ae506752e3581474877ba8e216a849cfcbe | Rust | Byron/effective-java-examples | /src/main/rust/chapter02/item05/src/lib.rs | UTF-8 | 511 | 2.96875 | 3 | [] | no_license | extern crate chrono;
use chrono::*;
pub fn is_baby_boomer(date: &Date<UTC>) -> bool {
BabyBoomChecker::new().is_baby_boomer(date)
}
pub struct BabyBoomChecker {
start: Date<UTC>,
end: Date<UTC>
}
impl BabyBoomChecker {
pub fn new() -> BabyBoomChecker {
BabyBoomChecker {
start: UT... | true |
6cbaa22825c54cd33d21f987cd11b8f78689488f | Rust | kompics/kompicsbenches | /shared_rust/src/helpers/graphs.rs | UTF-8 | 11,388 | 3.21875 | 3 | [] | no_license | use std::{
cmp::{Eq, PartialEq, PartialOrd},
fmt, mem,
};
use rand::{rngs::SmallRng, Rng, SeedableRng};
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Phase {
Initial,
Normal(usize),
}
impl Phase {
pub fn k(&self) -> usize {
match self {
Phase::Normal(k) => *k,
... | true |
709d6c06b5535dba1bc5d88d59002b0a76a6c95f | Rust | msgpo/MLS-protocol-crypto | /src/hash.rs | UTF-8 | 1,029 | 2.921875 | 3 | [
"MIT"
] | permissive | use crypto_algorithms::HashType;
/// Hashing
pub trait Hash {
/// The return type of [`Hash::hasher()`], a stateful hasher.
type StatefulHasher;
/// The error type returned by [`Hash`].
type Error;
/// The return type of the [`Hash::hash`] function.
type Digest;
/// Single-shot hash
... | true |
44e3c3bdc9ddfac20b25ecb1fde65dd382d2bab0 | Rust | Tails8521/parser | /src/demo/message/classinfo.rs | UTF-8 | 1,065 | 2.6875 | 3 | [] | no_license | use bitbuffer::{BitRead, BitReadSized, LittleEndian};
use crate::demo::message::stringtable::log_base2;
use crate::{ReadResult, Stream};
use std::cmp::min;
#[derive(BitReadSized, Debug)]
pub struct ClassInfoEntry {
#[size = "input_size"]
class_id: u16,
class_name: String,
table_name: String,
}
#[deri... | true |
d9bfd3a3dc901a4695449b53c8cc16457734661a | Rust | liurenjie1024/blitzwing | /blitzwing-native/hdfs-rs/src/fs/file_status.rs | UTF-8 | 2,664 | 2.75 | 3 | [] | no_license | use crate::{
error::{HdfsLibError, Result},
fs::path::{FsPath, FsPathBuilder},
hadoop_proto::hdfs::{HdfsFileStatusProto, HdfsFileStatusProto_FileType},
};
use std::convert::TryFrom;
#[derive(Debug, Clone)]
pub enum FileStatus {
File(FileInfo),
Dir(DirInfo),
}
#[derive(Debug, Clone)]
pub struct FileStat {
... | true |
1ead038c09f1e2562a049c83a77da06c070d2225 | Rust | ruuda/tako | /src/fetch.rs | UTF-8 | 7,623 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | // Tako -- Take container image.
// Copyright 2018 Arian van Putten, Ruud van Asseldonk, Tako Marks.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
//! Cont... | true |
8a996b0d9e9f1e59d87f2a4bef1b5f5d05a56ab8 | Rust | kali/advent2020 | /day18/src/main.rs | UTF-8 | 1,432 | 2.953125 | 3 | [] | no_license | use nom::branch::alt;
use nom::character::complete::{char as cchar, digit1, multispace0};
use nom::combinator::{map, map_res};
use nom::multi::{fold_many0, separated_list1};
use nom::sequence::{delimited, pair};
use nom::IResult;
fn main() {
let lines = std::fs::read_to_string("input").unwrap();
dbg!(lines.lin... | true |
93ebbba0b5df874ff2fc6b46bd5488a052c9f3f1 | Rust | sral/aoc2019 | /day_3/src/main.rs | UTF-8 | 9,046 | 3.46875 | 3 | [] | no_license | // --- Day 3: Crossed Wires ---
//
// The gravity assist was successful, and you're well on your way to the Venus
// refuelling station. During the rush back on Earth, the fuel management system
// wasn't completely installed, so that's next on the priority list.
//
// Opening the front panel reveals a jumble of wires.... | true |
4dbc262793e8a122533422b4702e39091c8e6e8f | Rust | brock-ff/cargo-make-test | /src/main.rs | UTF-8 | 1,488 | 3.578125 | 4 | [] | no_license | #[allow(unused_imports)]
#[macro_use]
extern crate lazy_static;
use std::sync::Mutex;
fn main() {
println!("Hello, world!");
}
pub struct Thing {
pub value: u64,
}
#[cfg(test)]
mod tests {
use super::*;
lazy_static! {
#[derive(Debug)]
// THING will be reset for every test run from c... | true |
c7f17ffdcea44c50ed24cd055b58df3f54f8e52a | Rust | saxelsen/learning-rust | /week_01/duffau/fibonacci/src/main.rs | UTF-8 | 209 | 3.609375 | 4 | [] | no_license | fn main() {
println!("Fibonacci");
let n = 10;
println!("n = {}, Fibonacci = {}",n, fib(n));
}
fn fib(n:i32) -> i32 {
if n == 0 {
0
} else if n == 1 {
1
} else {
fib(n-1) + fib(n-2)
}
} | true |
26c4cc47d72e8137783d33f55a9b901f5d673835 | Rust | jihoonson/rust-example | /src/qsort_example.rs | UTF-8 | 729 | 2.796875 | 3 | [] | no_license | extern crate rayon;
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
let pivot = v.len() - 1;
let mut i = 0;
for j in 0..pivot {
if v[j] <= v[pivot] {
v.swap(i, j);
i += 1;
}
}
v.swap(i, pivot);
i
}
pub fn qsort(vec: &mut [i32]) {
if vec.len()... | true |
3f59e01786193f34fb1dc60dff32da7e7114f42f | Rust | wangshankun/rcnn-optimize | /lab_test/rust_struct_order/src/main.rs | UTF-8 | 2,395 | 3.609375 | 4 | [] | no_license | use std::cmp::Ordering;
use rand::Rng; //导入外部的包... 记得修改toml文件
//保证age是可比较的
pub struct Person<T : std::cmp::PartialOrd> {
age: T,
}
//注意泛型T的位置
impl<T> Person<T> where T:std::cmp::PartialOrd{
//也可impl<T:std::cmp::PartialOrd> Person<T>
pub fn new(a:T) -> Self{
Person {age:a}
}
}
//让Person可比较大小, ... | true |
745deaf62cdf469219d73054f49fe1ba553bed26 | Rust | suguru03/leetcode | /algorithms/0645.Set Mismatch/solution.rs | UTF-8 | 791 | 3.140625 | 3 | [] | no_license | pub struct Solution;
impl Solution {
pub fn find_error_nums(nums: Vec<i32>) -> Vec<i32> {
let mut checks = vec![0_i8; nums.len()];
let mut result = Vec::with_capacity(2);
for &n in &nums {
let i = (n - 1) as usize;
checks[i] ^= 1;
if checks[i] == 0 {
... | true |
256feca3569fdfdb548d88320748877b6816fd81 | Rust | daniyalsuhail-ds/PIAIC-rust-Q1 | /Assignment 2/q7/main/src/main.rs | UTF-8 | 139 | 2.984375 | 3 | [] | no_license | struct Rectangle {
width: u32,
height: u32}
fn main(){
let rect1 = Rectangle{
width: 150,
height: 100
};
println!("{}",rect1.width );
} | true |
9bce36664510e884b4eb14ee26db6f865e686b56 | Rust | wasmerio/wasmer | /lib/cli/src/commands/compile.rs | UTF-8 | 2,763 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::store::StoreOptions;
use crate::warning;
use anyhow::{Context, Result};
use clap::Parser;
use std::path::PathBuf;
use wasmer::*;
#[derive(Debug, Parser)]
/// The options for the `wasmer compile` subcommand
pub struct Compile {
/// Input file
#[clap(name = "FILE")]
path: PathBuf,
/// Output ... | true |
36be21b5ea0cf1f3ecfb802b86c6851b045ba058 | Rust | KeyMaster-/imgui-rs | /src/internal.rs | UTF-8 | 1,763 | 3.15625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::slice;
#[repr(C)]
pub struct ImVector<T> {
size: i32,
capacity: i32,
pub(crate) data: *mut T,
}
impl<T> ImVector<T> {
pub unsafe fn as_slice(&self) -> &[T] {
slice::from_raw_parts(self.data, self.size as usize)
}
}
#[test]
fn test_imvector_memory_layout() {
use std::mem;
... | true |
84028e00d58c9a0aca8d30830f6d4b6d4c9ddfaa | Rust | MKamelll/uhm | /src/parser.rs | UTF-8 | 2,005 | 3.53125 | 4 | [
"MIT"
] | permissive | /*
* Parse the command to be aliased into a
* main app name and the args given to
* the app.
* i.e app -> [git], args -> [status]
*/
// Use
use std::env;
use std::io;
use std::process;
// opts
// Parsed command
#[derive(Debug)]
struct ParsedCommand<'a> {
command: &'a str,
args: Option<Vec<&'a str>>,
}
// Al... | true |
20d356f2fd2d368c7e3b0049d0d75850a0a67c05 | Rust | manueldeval/rust_synth | /src/granular/src/granular_osc_receiver.rs | UTF-8 | 2,933 | 2.703125 | 3 | [] | no_license | use std::sync::{Arc, Mutex};
use dsp::core::OscMessageHandler;
use rosc::{OscMessage, OscType};
use crate::GranularController;
// Osc receiver
pub struct GranularOscMessageHandler {
synth_controller: Arc<Mutex<GranularController>>,
}
impl GranularOscMessageHandler {
pub fn new(synth_controller: Arc<Mutex<Gr... | true |
97e353d5d076577c9a21e94a705fd53741710525 | Rust | arjunlalshukla/aurum_actors | /aurum_actors/src/core/remoting.rs | UTF-8 | 4,480 | 2.734375 | 3 | [] | no_license | use crate::core::{ActorId, Case, RootMessage, UnifiedType};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use std::hash::Hash;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::{cmp::PartialEq, marker::PhantomData};
use std::{fmt, str::FromStr};
use tokio::net::lookup_h... | true |
4e927f72c258729e09307b37627a1013f80e349a | Rust | chin0/llrl | /llrl0/src/pattern_matching.rs | UTF-8 | 1,145 | 2.59375 | 3 | [] | permissive | mod matrix;
mod pattern;
mod row;
pub use matrix::Matrix;
pub use pattern::{FiniteCon, Pattern, Tag};
pub use row::Row;
#[cfg(test)]
mod tests;
// TODO: Compare performance with im-rc
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Hash)]
pub enum Error {
Useless(Row),
NonExhaustive(Matrix),
}
pub f... | true |
9c4b7513f74ed9a1fd27cafb6575bc9a55c3e0d9 | Rust | jens1o/elder-solutions | /src/problem-one-hundred-and-two/src/main.rs | UTF-8 | 2,322 | 3.375 | 3 | [] | no_license | use std::fs;
use std::io;
use std::time::SystemTime;
#[derive(Debug)]
struct Point {
x: f32,
y: f32,
}
#[derive(Debug)]
struct Triangle {
a: Point,
b: Point,
c: Point,
}
fn main() -> Result<(), io::Error> {
let triangles = fs::read_to_string("p102_triangles.txt")?;
let benchmark_start = ... | true |
8fb34e3bc9e4cd7181d86bb152e127257ad89ad2 | Rust | astrotars/webrtc | /src/dtls/dtls_transport_state.rs | UTF-8 | 3,916 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::fmt;
/// DTLSTransportState indicates the DTLS transport establishment state.
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum DTLSTransportState {
Unspecified = 0,
/// DTLSTransportStateNew indicates that DTLS has not started negotiating
/// yet.
New = 1,
/// DTLSTransportStateConnecti... | true |
332e4a4588a30ea626640b8a5ac2e7914eab7c48 | Rust | deep-rust/deep | /deep/src/tensor.rs | UTF-8 | 3,469 | 3.109375 | 3 | [
"MIT"
] | permissive | use crate::{Backend, Graph, Input, Internal, Op};
use rand_core::RngCore;
use std::cell::RefCell;
use std::ops::{Add, Sub};
use std::rc::Rc;
pub struct Tensor {
graph: Rc<RefCell<Graph>>,
input: Input,
}
impl Tensor {
pub fn train_const(shape: Vec<usize>, value: f64) -> Self {
let mut graph: Graph... | true |
c9e0a2cb9f526d591db5bea9ab16092ce449d4d4 | Rust | Felerius/findminhs | /src/instance.rs | UTF-8 | 11,930 | 2.75 | 3 | [
"MIT"
] | permissive | use crate::{
create_idx_struct,
data_structures::{cont_idx_vec::ContiguousIdxVec, skipvec::SkipVec},
small_indices::SmallIdx,
};
use anyhow::{anyhow, ensure, Error, Result};
use log::{info, trace};
use serde::Deserialize;
use std::{
fmt::{self, Display, Write as _},
io::{BufRead, Write},
mem,
... | true |
48acb1baa5d43d11ff97a9a9c18f378a1a81e336 | Rust | dpetersen/gh-keys | /src/client.rs | UTF-8 | 1,561 | 2.59375 | 3 | [
"MIT"
] | permissive | use rustc_serialize::json;
use hyper;
use hyper::{Client, header};
use std::io::Read;
#[derive(RustcDecodable, Debug)]
pub struct Key {
pub id: u32,
pub key: String
}
impl Key {
pub fn to_authorized_keys_line(&self) -> String {
// TODO hardcoded username, need to set it for the whole collection?
... | true |
083c4f32d87356871f1f71a4e06e9e9c0037b19f | Rust | meltedot/utile_cli | /src/lib.rs | UTF-8 | 1,883 | 3.03125 | 3 | [] | no_license | pub mod cli;
#[cfg(test)]
mod tests {
use super::*;
use cli::*;
#[test]
fn term() {
Terminal::new();
}
#[test]
fn output() {
let t = Terminal::new();
t.out("Hello ".into());
t.outln(" World!".into());
t.outbr();
t.outln("This is a test.".into());
}
#[test]
fn input() {
... | true |
47ec7513f90f47188fc19ec0a509e0ed8cac9805 | Rust | henrikno/proteus | /src/parser/errors.rs | UTF-8 | 1,973 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::actions::getter::namespace::Error as GetterNamespaceError;
use crate::actions::setter::namespace::Error as SetterNamespaceError;
use crate::errors::Error as JSONError;
use serde_json::error::Error as SerdeJSONError;
use snafu::Snafu;
/// This type represents all possible errors that an occur while parsing t... | true |
3ae5f7e579ebbad968a47c3ec551c65309d7f211 | Rust | PeterW-LWL/mail | /headers/src/header_components/phrase_list.rs | UTF-8 | 4,229 | 2.640625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use soft_ascii_string::SoftAsciiChar;
use vec1::{Vec1, Size0Error};
use internals::error::EncodingError;
use internals::encoder::{EncodingWriter, EncodableInHeader};
use ::{HeaderTryFrom, HeaderTryInto};
use ::error::ComponentCreationError;
use super::Phrase;
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struc... | true |
0c83e94547fc3fb2ae222c86aa378e0858ed25b8 | Rust | Ablexxive/rust_play | /bevy/scene_test/src/text_play.rs | UTF-8 | 3,313 | 2.671875 | 3 | [] | no_license | use bevy::{
diagnostic::{Diagnostics, FrameTimeDiagnosticsPlugin},
prelude::*,
};
// A unit struct to help identify the FPS UI component, since there may be many Text components
struct FpsText;
fn text_update_system(diagnostics: Res<Diagnostics>, mut query: Query<(&mut Text, &FpsText)>) {
for (mut text, _... | true |
3537459205c74a04c000ebf0bc77123644b39520 | Rust | Repolak/ArmaRadio | /extension/core/src/lib.rs | UTF-8 | 3,549 | 2.515625 | 3 | [] | no_license | use std::collections::HashMap;
use std::sync::Mutex;
use alto::{Alto, DeviceObject};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use rust_embed::RustEmbed;
#[macro_use]
extern crate log;
mod source;
pub use source::SoundSource;
mod vector3;
pub use vector3::Vector3;
#[derive(RustEmbed)]
#[f... | true |
7b45b88040a77d4931f94aba5f3813ab07216556 | Rust | wasmerio/wasmer | /lib/api/src/jsc/externals/table.rs | UTF-8 | 4,975 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::errors::RuntimeError;
use crate::store::{AsStoreMut, AsStoreRef};
use crate::value::Value;
use crate::vm::VMExternTable;
use crate::vm::{VMExtern, VMFunction, VMTable};
use crate::{FunctionType, TableType};
use rusty_jsc::{JSObject, JSValue};
#[derive(Debug, Clone, PartialEq)]
pub struct Table {
pub(cra... | true |
a09dca63d2e80e264cf9baa3d741fb70358391cf | Rust | JoshFourie/sim-rs | /src/test/zombie/agents/actions/interaction/skirmish.rs | UTF-8 | 2,450 | 2.71875 | 3 | [] | no_license | use crate::test::zombie;
use zombie::agents;
use agents::package;
use agents::{DeadOrAlive};
use crate::context::grid;
use log::*;
use std::ops::{Div, SubAssign};
pub struct Skirmish<'a> {
lhs: &'a package::Package,
rhs: &'a package::Package
}
impl<'a> Skirmish<'a> {
pub fn new(lhs: &'a package::Pack... | true |
3556ca21a5d386765863e79c45f254984b41bfa6 | Rust | ZcashFoundation/zebra | /zebra-rpc/src/methods/get_block_template_rpcs/types/zec.rs | UTF-8 | 6,434 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! ZEC amount formatting.
//!
//! The `f64` values returned by this type should not be used in consensus-critical code.
//! The values themselves are accurate, but any calculations using them could be lossy.
use std::{
fmt,
hash::{Hash, Hasher},
ops,
str::FromStr,
};
use zebra_chain::amount::{self, A... | true |
f7b7c84358da87e4d3f99baee227458da166905b | Rust | maboesanman/cozal | /transposer/src/schedule_storage.rs | UTF-8 | 6,524 | 3 | 3 | [
"MIT"
] | permissive | use core::borrow::Borrow;
use core::hash::Hash;
use core::ops::Deref;
use std::rc::Rc;
use std::sync::Arc;
pub trait StorageFamily: Copy + 'static {
type OrdMap<K: Ord + Eq + Clone, V: Clone>: OrdMapStorage<K, V>;
type HashMap<K: Hash + Eq + Clone, V: Clone>: HashMapStorage<K, V>;
// someday we want to dr... | true |
62b4c388b0fa5fdb4d63295c81a15ab4e8fd7915 | Rust | MaulingMonkey/bgfx-rs | /examples/common/mod.rs | UTF-8 | 5,218 | 2.625 | 3 | [
"ISC"
] | permissive | // Copyright (c) 2015-2016, Johan Sköld.
// License: http://opensource.org/licenses/ISC
extern crate bgfx;
extern crate glutin;
extern crate libc;
use bgfx::{Bgfx, PlatformData, RenderFrame};
use glutin::{Api, GlRequest, Window, WindowBuilder};
use std;
use std::env;
use std::fs::File;
use std::io::Read;
use std::s... | true |
cce0931b7adbdbc7107b4ffa2574b3b539c197c8 | Rust | dmikusa/pc4d-rust | /src/bin/pkverify/main.rs | UTF-8 | 955 | 2.71875 | 3 | [] | no_license | use sodiumoxide::crypto::sign;
use std::env;
fn main() {
if env::args().count() != 3 {
println!(
"Usage: {} publicKey signedMessage",
env::args().nth(0).unwrap()
);
println!(" publicKey: hex-encoded public key");
println!(" signedMessage: base64-encoded... | true |
362d80d0a3e31e87126c0a3baa776574cd4eea22 | Rust | M-Isonni/learning_Rust | /src/references.rs | UTF-8 | 1,315 | 4.25 | 4 | [] | no_license | pub fn make_ref(){
let mut s1 = String::from("hello");
println!("s1 before changing is: {}", s1);
change(&mut s1);
let len = calculate_length(&s1);
// let r1 = &mut s1;
// let r2 = &mut s1; //only one mutable reference to an object can be active at a time!
//RECAP:
//you CANNOT h... | true |
62a893132e8ea3633e65eb4c9a40c838fe4166ef | Rust | D3fus/mpd_client | /src/errors.rs | UTF-8 | 3,969 | 2.75 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use tokio::sync::{mpsc::error::SendError, oneshot::error::RecvError};
use std::error::Error;
use std::fmt;
use crate::commands::responses::TypedResponseError;
use crate::raw::{ErrorResponse, Frame, MpdProtocolError};
/// Errors which can occur when issuing a command.
#[derive(Debug)]
pub enum CommandError {
/// ... | true |
9f0baeb066de8d3ffa88cdbdc1c31861b2df9251 | Rust | nirasan/rust-lifegame | /src/main.rs | UTF-8 | 5,396 | 2.96875 | 3 | [] | no_license | #[macro_use] extern crate crossbeam_channel;
extern crate rand;
use crossbeam_channel::{unbounded, Sender, Receiver, tick};
use std::thread;
use std::time::Duration;
use std::collections::HashMap;
const WIDTH: usize = 10;
const HEIGHT: usize = 10;
const TIMEOUT: u64 = 10;
fn main() {
// create life game render... | true |
5f590c76c62e0206ac808115921f9b3f9ee92c5a | Rust | Azure/azure-sdk-for-rust | /sdk/storage_blobs/src/options/blob_expiry.rs | UTF-8 | 1,181 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LGPL-2.1-or-later"
] | permissive | use azure_core::{date, headers::Headers};
use time::OffsetDateTime;
const EXPIRY_TIME: &str = "x-ms-expiry-time";
const EXPIRY_OPTION: &str = "x-ms-expiry-option";
#[derive(Debug, Clone)]
pub enum BlobExpiry {
RelativeToCreation(u64),
RelativeToNow(u64),
Absolute(OffsetDateTime),
NeverExpire,
}
impl ... | true |
9c6472781d20ff01d99f75c8e606b54a6154c663 | Rust | jackpot51/artifact-data | /src/cache.rs | UTF-8 | 966 | 2.6875 | 3 | [] | no_license | //! #SPC-data-cache
//!
//! This defines the caches, currently there are two:
//! - NameCache: cache of name tokens.
//! - PathCache: cache of absolute paths. The logic lives here
use prelude::*;
use dev_prelude::*;
use name::{Type, Name};
lazy_static!{
/// global cache of names
pub(crate) static ref NAME_CACH... | true |
76e09411c16b58f173207ca0c3ee2cb940033261 | Rust | nao-kobayashi/tokio_tutorials | /tokio_echo/echo_server/src/main.rs | UTF-8 | 1,171 | 2.65625 | 3 | [] | no_license | use tokio::io;
use tokio::net::TcpListener;
#[tokio::main]
async fn main() -> io::Result<()> {
let listener = TcpListener::bind("127.0.0.1:6142").await?;
loop {
let (socket, _) = listener.accept().await?;
//echo_io_copy(socket).await;
echo_manual_copy(socket).await;
}
}
async fn e... | true |
706062bac13ebd0f5964c5fd2ae1ff864f730e43 | Rust | pretty-wise/netcode | /network/src/shared/bits.rs | UTF-8 | 8,884 | 3.25 | 3 | [] | no_license | use std::{
io::{Read, Write},
slice,
};
#[derive(Debug)]
pub enum Error {
OutOfMemory,
InvalidArgument,
ValueOutOfBounds,
}
pub struct BitWriter<'a> {
dest: &'a mut [u8],
scratch: u64,
scratch_bits: i32,
capacity: i64,
}
impl<'a> BitWriter<'a> {
pub fn new(dest: &'a mut [u8]) ... | true |
776da3c35ec5c03898f7acb733757257d88f4f42 | Rust | joshuabenuck/unblock | /src/main.rs | UTF-8 | 24,347 | 2.671875 | 3 | [] | no_license | /*
Add undo: Build stack of moves
*/
use coffee::{
graphics::{Color, Frame, Mesh, Point, Rectangle, Shape, Window, WindowSettings},
input::{keyboard, keyboard::KeyCode, mouse, ButtonState, Event, Input, KeyboardAndMouse},
load::Task,
Game, Result, Timer,
};
use itertools::put_back;
use std::collections... | true |
ed6610a630c6a2ffdbecb343cc029be522d319b8 | Rust | yodeskir/gitbox | /gitbox-service/src/gitinit.rs | UTF-8 | 575 | 2.78125 | 3 | [] | no_license | use git2::build::CheckoutBuilder;
use git2::build::RepoBuilder;
use git2::Error;
use git2::FetchOptions;
use git2::RemoteCallbacks;
use git2::Repository;
use std::path::Path;
pub fn do_clone<'a>(url: &str, path: &str) -> Result<Repository, Error> {
let cb = RemoteCallbacks::new();
let co = CheckoutBuilder::new();
l... | true |
2878eb883c6ef9fe05649a5fb69a6e50da2a02b3 | Rust | AlexGrasley/Web-Movie-Database | /backend/src/theater.rs | UTF-8 | 4,367 | 2.8125 | 3 | [] | no_license | use crate::model::RowTranslation;
use crate::model::Theater;
use crate::shared::*;
use crate::DBConn;
use mysql::params;
use rocket::{self, delete, get, http::Status, patch, post};
use rocket_contrib::json::Json;
#[get("/<id>")]
pub fn select_theater_by_id_handler(mut conn: DBConn, id: u64) -> Result<Json<Theater>, S... | true |
b73a1ed4f13b4f7f1036431811b25a2f11787e34 | Rust | simonw/python-ext-wasm | /src/value.rs | UTF-8 | 1,143 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! The `Value` Python class to build WebAssembly values.
use pyo3::{class::basic::PyObjectProtocol, prelude::*};
use wasmer_runtime::Value as WasmValue;
#[pyclass]
/// The `Value` class represents a WebAssembly value.
pub struct Value {
pub value: WasmValue,
}
#[pymethods]
impl Value {
#[staticmethod]
f... | true |
8ce020037ffac2a3444b037a9d0d57970fa1edf3 | Rust | falconre/falcon | /lib/lib.rs | UTF-8 | 5,397 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | #![recursion_limit = "128"]
//! Falcon: A Binary Analysis Framework in Rust.
//!
//! Falcon is a framework in rust for implementing formal analyses over binary
//! programs. A quick synopsis of Falcon's modules:
//!
//! * **analysis** - A fixed-point engine and methods for abstract interpretation
//! over Falcon IL. E... | true |
177436dbb9189bb741145008d8a1a7ceb8bd04ec | Rust | Vicfred/codeforces-rust | /watermelon.rs | UTF-8 | 277 | 2.9375 | 3 | [
"BSD-3-Clause"
] | permissive | // https://codeforces.com/problemset/problem/4/A
use std::io;
fn main() {
let mut guess = String::new();
io::stdin().read_line(&mut guess).unwrap();
let w: i32 = guess.trim().parse().unwrap();
println!("{}", if w >= 4 && w % 2 == 0 { "YES" } else { "NO" });
}
| true |
75afb6f9cba0ac9511d61ecac77f66a717282d62 | Rust | HerringtonDarkholme/leetcode | /src/binary_tree_level_order_traversal.rs | UTF-8 | 1,908 | 3.375 | 3 | [] | no_license | use crate::util::tree::TreeNode;
pub struct Solution;
use std::rc::Rc;
use std::cell::RefCell;
// 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>>>,
// }
//
// ... | true |
029385a08424348753fe16b91dba1267477da893 | Rust | Smithay/drm-rs | /src/util.rs | UTF-8 | 570 | 2.515625 | 3 | [
"MIT"
] | permissive | //! Utilities used internally by this crate.
use crate::control::{from_u32, RawResourceHandle};
pub unsafe fn transmute_vec<T, U>(from: Vec<T>) -> Vec<U> {
let mut from = std::mem::ManuallyDrop::new(from);
Vec::from_raw_parts(from.as_mut_ptr() as *mut U, from.len(), from.capacity())
}
pub unsafe fn transmut... | true |
941643f4f86648fc4647e9fb0d83dba7ba794b0c | Rust | tekjar/rust-learn | /generics_and_traits/4_traitsbounds_mistake1.rs | UTF-8 | 1,787 | 3.84375 | 4 | [
"MIT"
] | permissive | /* Writing a function which adds 2 to every element of vector and a function to multiply 2
to every element of the vector */
/* NOTES: OWNERSHIP AND BORROW RULES
1. Only one owner at a time
2. Only 1 active mutable borrow at a time
3. Every other borrow after a shared borrow should be a shared borrow... | true |
c5e3a71539eba51d2f109301b442e8abf46af6c5 | Rust | ivan-filonov/online-challenges | /codingame/winamax/my.rs | UTF-8 | 12,742 | 2.734375 | 3 | [] | no_license | use std::{io, iter};
use std::collections::{HashSet, HashMap};
use std::iter::FromIterator;
use std::ops::RangeFull;
use paths_builder::Path;
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
pub struct Pt {
... | true |
59c02decdea90c5737d6537d985021d2a02043f0 | Rust | ybyygu/rust-lbfgsb | /tests/driver1.rs | UTF-8 | 2,125 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | // [[file:~/Workspace/Programming/rust-libs/l-bfgs-b-c/lbfgsb.note::*driver1.rs][driver1.rs:1]]
use anyhow::Result;
use lbfgsb::*;
use vecfx::*; // for calculate gradient norm
/// Compute function value f for the sample problem.
///
/// Evaluate f(x) and g(x) at current `x`.
///
/// Returns Err will cancel L-BFGS-B mi... | true |
53c93f18640b5eb21eada28b38621bab44e262da | Rust | BraedonWooding/CVM | /src/interpreter/mod.rs | UTF-8 | 4,877 | 3.5625 | 4 | [
"MIT"
] | permissive | pub mod instructions;
/// == CVM Instruction Set ==
/// Loosely based off a mixture of Mips and x86
/// Important characteristics
/// - Human readable to a degree (when in printable format)
/// == Registers in CVM ==
/// To support bizarre registers in languages like Mips or x86
/// CVM has 'RegisterConfigs' which ju... | true |
4f23c9fcf319c49d870af7c34b8c932f7951f9a1 | Rust | RevelationOfTuring/Rust-exercise | /src/enums.rs | UTF-8 | 3,340 | 3.984375 | 4 | [
"Apache-2.0"
] | permissive | // Create an `enum` to classify a web event. Note how both
// names and type information together specify the variant:
// `PageLoad != PageUnload` and `KeyPress(char) != Paste(String)`.
// Each is different and independent.
#[cfg(test)]
mod tests {
use std::borrow::ToOwned;
enum WebEvent {
// An `enum... | true |
c234228d3863dc3a677693ae3db8353aa867876c | Rust | PyroFlareX/newport | /crates/newport_os/src/dialog.rs | UTF-8 | 2,642 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::win32::*;
use crate::window::Window;
use std::{
ptr::{ null, null_mut },
mem::size_of,
};
pub struct DialogBuilder<'a> {
window: &'a Window,
_title: Option<String>,
extensions: Vec<(String, String)>,
default_extension: usize,
}
impl<'a> DialogBuilder<'a> {
pub fn new(w... | true |
ffc972f6b99bb1ab4b7dfcbdc1f74192ad9e8304 | Rust | Phate6660/rsPhate | /src/commands/ww.rs | UTF-8 | 6,320 | 3.078125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use log::error;
use serenity::{
framework::standard::{macros::command, Args, CommandResult},
model::channel::Message,
prelude::*,
};
#[command]
#[description = "Bot will reply with pretty embed explaining why the topic is bad."]
#[usage = "topic"]
#[example = "apple"]
#[example = "steam"]
#[example = "syst... | true |
b8fb6b1cb011108d8893740d2795248d2445d684 | Rust | dicej/rust-postgres | /tokio-postgres/src/builder.rs | UTF-8 | 6,229 | 2.875 | 3 | [
"MIT"
] | permissive | use std::collections::hash_map::{self, HashMap};
use std::iter;
use std::str::{self, FromStr};
use tokio_io::{AsyncRead, AsyncWrite};
#[cfg(feature = "runtime")]
use crate::proto::ConnectFuture;
use crate::proto::HandshakeFuture;
#[cfg(feature = "runtime")]
use crate::{Connect, MakeTlsMode, Socket};
use crate::{Error,... | true |
39db4f951867b1846420a4878f1c5c9f5d8fa088 | Rust | scott113341/advent_of_code_2018 | /day_23/src/nanobot.rs | UTF-8 | 1,057 | 3.515625 | 4 | [] | no_license | use regex::Regex;
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
pub struct Nanobot {
pub x: isize,
pub y: isize,
pub z: isize,
pub r: isize,
}
impl Nanobot {
pub fn parse(input: &String) -> Nanobot {
let re = Regex::new(r"pos=<(-?\d+),(-?\d+),(-?\d+)>, r=(\d+)").unwrap();
let caps =... | true |
0434ee0d4b77eaa42d2ad24abb3b59c36641cd22 | Rust | FreddyMaster/rustfetch | /shell.rs | UTF-8 | 253 | 2.640625 | 3 | [] | no_license | use std::{env, env::VarError};
pub fn get_shell() -> Result<String, VarError> {
match env::var("SHELL") {
Ok(s) => {
let s = s.split('/').last().unwrap().to_string();
Ok(s)
}
Err(e) => Err(e),
}
}
| true |
4f79eb594746083abd3227ebaf38ff39c5bd0f4b | Rust | Elabajaba/hierarchical_pathfinding_example | /src/main.rs | UTF-8 | 4,065 | 3.03125 | 3 | [] | no_license | use hierarchical_pathfinding::prelude::*;
use hashbrown::HashMap;
fn main() {
// profiling::register_thread!("Main Thread");
let width = 1024;
let height = 1024;
// profiling::scope!("Main Thread");
let mut map = Map::new(width, height);
let start = (0, 0);
// let end = (31, 31);
//... | true |
b2189e2966141bc5db32398bfa1015f3518f100a | Rust | mathion-math/mathion | /src/symbols/polynomial.rs | UTF-8 | 8,007 | 2.734375 | 3 | [
"CC0-1.0"
] | permissive | // =======================================================================
// Copyleft mathion 2018-∞.
// Distributed under the terms of the CC0 “No Rights Reserved”.
// (See accompanying file COPYING or copy at
// https://creativecommons.org/publicdomain/zero/1.0/)
// =============================================... | true |
0c677ff075d88dc5d3efeee52a7a68b635c23b21 | Rust | k124k3n/competitive-programming-answer | /codesignal/firstNotRepeatingCharacter.rs | UTF-8 | 284 | 2.734375 | 3 | [
"MIT"
] | permissive | fn firstNotRepeatingCharacter(s: String) -> char {
let mut alph = [0u16; 26];
for i in s.as_bytes() {
alph[(i - 'a' as u8) as usize] += 1;
}
for i in s.chars() {
if alph[i as usize - 'a' as usize] == 1 {
return i;
}
}
'_'
}
| true |
f234925b8c769090faef4ae83c012a457e0dde08 | Rust | tagantroy/acc_assist | /accd_core/src/accd_car_info.rs | UTF-8 | 1,564 | 2.953125 | 3 | [] | no_license | use std::fmt;
use crate::accd_driver_info::ACCDDriverInfo;
use crate::accd_enums::NationalityEnum;
#[derive(Debug, Clone, PartialEq)]
pub struct ACCDCarInfo {
pub car_index: u16,
pub car_model_type: u8,
pub team_name: String,
pub race_number: i32,
pub cup_category: u8,
pub current_driver_index... | true |
7ac2bc82ba0b042d5eadb69c2746b086095c36c3 | Rust | julianandrews/adventofcode | /2021/rust/src/bin/day11.rs | UTF-8 | 4,645 | 3.203125 | 3 | [] | no_license | use aoc::aoc_error::AOCError;
use aoc::utils::get_input;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn main() -> Result<()> {
let input = get_input()?;
let map: OctopusMap = input.trim().parse()?;
println!("Part 1: {}", part1(map.clone()));
println!("Part 2: {}", part2(map))... | true |
05fd94d18f17f06e115f6480520a3f6472744ea2 | Rust | ten3roberts/sprocket_old | /sprocket/src/graphics/vulkan/descriptors.rs | UTF-8 | 10,473 | 2.65625 | 3 | [
"MIT"
] | permissive | use super::{Error, Result};
use super::{Sampler, Texture, UniformBuffer};
use ash::version::DeviceV1_0;
use ash::vk;
use serde::{Deserialize, Serialize};
use std::ptr;
use std::sync::Arc;
#[derive(Serialize, Deserialize, Eq, PartialEq, Clone)]
pub struct DescriptorSetLayoutSpec {
pub bindings: Vec<DescriptorSetLay... | true |
9d0f10e0953ce60ab65b67bf09dedc1a23b4df52 | Rust | tangkhaiphuong/rust-food-delivery | /src/common/uid.rs | UTF-8 | 4,246 | 3.25 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::str;
use base58::*;
/*
* @author Viet Tran <viettranx@gmail.com>
* @copyright 2019 Viet Tran <viettranx@gmail.com>
* @license Apache-2.0
*/
// UID is method to generate a virtual unique identifier for whole system
// its structure contains 62 bits: Local... | true |
506325717c21b388ae35bdda44bfa2a89a0cda9c | Rust | ojskrede/openslide-rust | /tests/convenience.rs | UTF-8 | 3,173 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Integration tests of the convenience module
//!
extern crate openslide;
extern crate failure;
extern crate float_cmp;
extern crate image;
use std::path::Path;
use float_cmp::ApproxEq;
use image::{RgbaImage};
fn get_slide() -> openslide::OpenSlide {
let filename = Path::new("assets/CMU-1-Small-Region.svs");
... | true |
d57cdd04435c3034115f3ed858d444668c71323e | Rust | BMeu/ReuralNetwork | /src/matrix/definition.rs | UTF-8 | 55,603 | 3.21875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2019 Bastian Meyer
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT o
// http://opensource.org/licenses/MIT>, at your option. This file may not be copied, modified, or
// distributed except according to those... | true |
81d1420c65770f01f1a7975a847c553a82632ce2 | Rust | divvun/divvunspell-sdk-python | /src/lib.rs | UTF-8 | 2,998 | 3.28125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::sync::Arc;
use divvunspell::{archive, speller};
use pyo3::prelude::*;
/// Use spell checker archives compatible with the [divvunspell] project.
///
/// divvunspell is intended to be a Rust implementation of [hfst-ospell],
/// so `.zhfst` speller archives should work.
///
/// To get started, open a speller ar... | true |
76da78dd3126c8f2cc45a9d18965c73ced3eff14 | Rust | MilesBreslin/Chunky-Bits | /src/file/weighted_location.rs | UTF-8 | 1,238 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::str::FromStr;
use serde::{
Deserialize,
Serialize,
};
use crate::file::Location;
#[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize)]
pub struct WeightedLocation {
#[serde(default = "WeightedLocation::default_weight")]
pub weight: usize,
pub location: Location,
}
impl... | true |
ee06afd19481a2f6dee74306bc0f38d0733ebf9f | Rust | xTibor/system-beeps-c64 | /tools/src/bin/pit2sid.rs | UTF-8 | 1,439 | 3.09375 | 3 | [] | no_license | use std::fs;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "pit2sid")]
struct Opt {
#[structopt(short = "i", long = "input")]
input_path: String,
#[structopt(short = "o", long = "output")]
output_path: String,
}
fn convert_pit_to_sid(pit_value: u16) -> u16 {
let freque... | true |
3a3a83627795878577d436d8d423ebb5cee47bed | Rust | T0mstone/tlib | /src/macros.rs | UTF-8 | 7,150 | 3.8125 | 4 | [] | no_license | /// Counts how many arguments it receives.
///
/// Example:
/// ```
/// # use tlib::count_args;
/// let n = count_args!(
/// (2), (3), (5)
/// );
/// assert_eq!(n, 3);
/// ```
#[macro_export]
macro_rules! count_args {
(@single $($t:tt)*) => { () };
($(($($x:tt)*)),*) => {
[$($crate::count_args!(@sin... | true |
964c3ec6ea7cf1fb74bab0a7ac91ac4fa0b96f39 | Rust | google/rrg | /crates/rrg-proto/src/convert.rs | UTF-8 | 1,688 | 3.140625 | 3 | [
"MIT"
] | permissive | // Copyright 2020 Google LLC
//
// Use of this source code is governed by an MIT-style license that can be found
// in the LICENSE file or at https://opensource.org/licenses/MIT.
//! Traits for conversions between types.
//!
//! This module provides utility traits similar to what `std::convert` does and
//! can be tho... | true |
0dc3d89f79cc5a318bbf068b3b962bb8212d94f4 | Rust | unconed/imgui-rs | /src/image.rs | UTF-8 | 6,510 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use super::{ImVec2, ImVec4, Ui};
use std::collections::HashMap;
use std::marker::PhantomData;
use std::os::raw::c_void;
use sys;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ImTexture(usize);
impl ImTexture {
pub fn id(self) -> usize {
self.0
}
}
impl From<usize> for... | true |
63a3e5bdc8a8764cd11a332547e0d8f951e927d1 | Rust | wulu90/leetcode | /src/implement_str_str.rs | UTF-8 | 1,938 | 3.3125 | 3 | [] | no_license | pub struct Solution;
impl Solution {
pub fn str_str(haystack: String, needle: String) -> i32 {
if needle.is_empty() {
return 0;
}
if haystack.is_empty() || haystack.len() < needle.len() {
return -1;
}
// very very very slow
for i in 0..haysta... | true |
3b6db40ff3ff5c20d061d16a01fb066b025b1192 | Rust | fmonniot/rmsync | /crates/rmcloud/src/archive.rs | UTF-8 | 2,646 | 2.71875 | 3 | [] | no_license | use super::DocumentId;
use serde_json::json;
use std::io::Write;
use zip::{result::ZipError, write::FileOptions, ZipWriter};
#[derive(Debug, thiserror::Error)]
pub enum ArchiveError {
#[error("Can't build the ZIP archive: {0}")]
Zip(#[from] ZipError),
#[error("Can't serialize json file: {0}")]
Json(#[... | true |
ba1f9c02e4501885080feff89fb0d30df07c2453 | Rust | k7f/ascetic | /rut/src/renderer.rs | UTF-8 | 2,410 | 2.59375 | 3 | [
"MIT"
] | permissive | use tracing::trace;
use ascetic_vis::{
Scene, Theme, TranslateScale,
backend::usvg::{Pixmap, FitTo, AsUsvgTree, render_to_pixmap},
};
pub struct Renderer {
pixmap: Option<Pixmap>,
size: (f64, f64),
margin: (f64, f64),
is_dirty: bool,
}
impl Renderer {
pub fn new(size: (f64, f64), m... | true |
049a7074976d2a020cc89b2d2bc7303158f1f05e | Rust | bossmc/cdrs | /src/types/list.rs | UTF-8 | 17,687 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::net;
use uuid::Uuid;
use frame::frame_result::{ColType, ColTypeOptionValue, ColTypeOption};
use types::{CBytes, AsRust};
use types::data_serialization_types::*;
use types::map::Map;
use types::udt::UDT;
use error::Result;
// TODO: consider using pointers to ColTypeOption and Vec<CBytes> instead of owning them... | true |
be5229a33dd8c2d5103806fb9af2fe2b93144785 | Rust | uberjay/uberjay-aoc | /src/day5.rs | UTF-8 | 1,509 | 2.96875 | 3 | [] | no_license | use rayon::prelude::*;
#[aoc_generator(day5)]
pub fn input_generator(input: &str) -> String {
input.trim().to_string()
}
fn reject_adjecent_pairs(chars: impl Iterator<Item = char>) -> String {
chars
.fold(Vec::new(), |mut nv: Vec<char>, b| {
if let Some(a) = nv.last() {
if ... | true |
e49d1d06fff3aa0788f0482fafad8413ac44ef67 | Rust | Corallus-Caninus/windows-rs | /crates/tests/win32/handles/tests/test.rs | UTF-8 | 3,897 | 2.796875 | 3 | [] | no_license | use windows::core::*;
use windows::Win32::Foundation::*;
use windows::Win32::Graphics::Gdi::*;
use windows::Win32::System::Registry::*;
use windows::Win32::System::Threading::LPPROC_THREAD_ATTRIBUTE_LIST;
#[test]
fn hwnd() {
let handle = HWND(0);
let _clone = handle.clone();
let _copy: HWND = handle;
a... | true |
fafc22aea8f0900908e3a206952c1a6f4cf5aeaa | Rust | bobbykaz/advent-of-code | /rust/src/years/y22/d19.rs | UTF-8 | 7,379 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::collections::{HashSet, VecDeque};
use crate::util;
pub fn run() {
//p1();
p2();
}
pub fn p1() {
let lines = util::read_file_into_lines("../input/y22/d19.txt");
let bps: Vec<Blueprint> = lines.iter().map(|l|parse_bp(l)).collect();
let quality:u32 = bps.iter()
.map(|b| ... | true |
8901be6eafa03db9f49efb4d4cb335177dfcfb95 | Rust | rustkel/date | /src/main.rs | UTF-8 | 280 | 2.796875 | 3 | [
"MIT"
] | permissive | mod date;
fn main() {
let d0 = date::Date::new(2000,2, 29);
let d = date::Date::new(2001,2, 28);
let g = date::Date::days_between_dates(&d0, &d);
match g {
Ok(days) => println!("{} - {}: {} days", d0, d, days),
Err(e) => println!("{}", e)
}
}
| true |
0bdacc1e8e646f767239f86be25dada952be288d | Rust | renyuneyun/projfs | /src/fsop.rs | UTF-8 | 1,817 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::ffi::OsString;
use std::fs::File;
use std::io::{self, Read, Seek, SeekFrom};
use std::os::unix::io::{FromRawFd, IntoRawFd};
use std::path::{Path, PathBuf};
use crate::libc_bridge as br;
use crate::libc_bridge::libc::c_int;
use crate::libc_bridge::libc_wrappers;
use fuse_mt::FileAttr;
pub fn real_path(target:... | true |
51765b362becc15f8c95ba47b7c516aca025e7c2 | Rust | bluejekyll/tokio | /tokio/src/runtime/thread_pool/queue/inject.rs | UTF-8 | 1,064 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::queue::Cluster;
use crate::task::Task;
pub(crate) struct Inject<T: 'static> {
cluster: Arc<Cluster<T>>,
}
impl<T: 'static> Inject<T> {
pub(super) fn new(cluster: Arc<Cluster<T>>) -> Inject<T> {
Inject { cluster }
}
/// Push a value ... | true |
a3480670cedcba0901b7d20b8dc573a0398c6d88 | Rust | AlgoQ/ta-rs | /examples/ema_serde.rs | UTF-8 | 559 | 2.96875 | 3 | [
"MIT"
] | permissive | use tars::indicators::ExponentialMovingAverage as Ema;
use tars::DataItema;
use tars::Nexta;
fn main() {
let mut ema = Ema::new(9).unwrap();
let mut reader = csv::Reader::from_path("./examples/data/AMZN.csv").unwrap();
for record in reader.deserialize() {
// Deserialize DataItema but ignore the `d... | true |
e4907634a11feb264a4bb027d3715e96f3808a6c | Rust | kellymclaughlin/pg-test | /hierarchy-test/src/opts.rs | UTF-8 | 2,170 | 2.859375 | 3 | [
"MIT"
] | permissive | extern crate clap;
use std::str::FromStr;
use clap::{App, Arg, ArgMatches};
pub enum Mode {
Baseline,
Database,
Schema,
Table
}
impl FromStr for Mode {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"baseline" => Ok(Mode::Baseline),... | true |
ab83e25f354f24b39ffc3f4b064502e7582782b3 | Rust | lorenzoditucci/calyx | /interp/src/interpreter/interpret_group.rs | UTF-8 | 8,122 | 2.859375 | 3 | [
"MIT"
] | permissive | //! Used for the command line interface.
//! Only interprets a given group in a given component
use crate::{
environment::InterpreterState,
utils::{AsRaw, RcOrConst},
};
use super::{
utils::{get_dest_cells, get_done_port, get_go_port, ConstPort},
Interpreter,
};
use crate::values::Value;
use calyx::ir... | true |
c0d2c314835b16b7f3a12f25cb62931bfa59c4d9 | Rust | mesalock-linux/crates-sgx | /vendor/wasmi/src/prepare/mod.rs | UTF-8 | 5,633 | 2.8125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use alloc::vec::Vec;
use crate::{
isa,
validation::{validate_module, Error, Validator},
};
use parity_wasm::elements::Module;
mod compile;
#[cfg(test)]
mod tests;
#[derive(Clone)]
pub struct CompiledModule {
pub code_map: Vec<isa::Instructions>,
pub module: Module,
}
pub struct WasmiValidation {
... | true |
d08a45391dcb376582e0f2362597fef150ad218a | Rust | n0name/math2d | /src/math/angle.rs | UTF-8 | 3,657 | 3.578125 | 4 | [] | no_license | use super::common::*;
use std::ops::*;
macro_rules! Op {
($op_trait: ident, $op_func: ident, $op: tt) => {
impl $op_trait for Angle {
type Output = Angle;
fn $op_func(self, rhs: Angle) -> Angle {
Angle{val: self.val $op rhs.val}
}
}
};
}
macr... | true |
64874debdc8b2bad352a14a778781d3d043bb5fa | Rust | bevyengine/bevy | /examples/3d/generate_custom_mesh.rs | UTF-8 | 9,999 | 3.1875 | 3 | [
"Apache-2.0",
"MIT",
"Zlib",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | // ! This example demonstrates how to create a custom mesh,
// ! assign a custom UV mapping for a custom texture,
// ! and how to change the UV mapping at run-time.
use bevy::prelude::*;
use bevy::render::mesh::Indices;
use bevy::render::mesh::VertexAttributeValues;
use bevy::render::render_resource::PrimitiveTopology;... | true |
42b68690580707abb482757a46969a0266026542 | Rust | dsbrgg/exercises | /rust/middle_char/src/main.rs | UTF-8 | 559 | 3.5 | 4 | [] | no_license | fn main() {
returns_expected();
}
fn get_middle_char(s: &str) -> &str {
let s_length = s.len();
if s_length <= 2 { return s; }
let is_even = s_length % 2 == 0;
let middle_start = (s_length / 2) - 1;
let middle_end = middle_start + 1;
if is_even {
&s[middle_start..=middle_end]
} else {
&s[mi... | true |
f168a0f2a6a9a9fe115e7ce75726aec74a50adb1 | Rust | ParzivalSec/RustySpark | /spark_core/src/pointer_util.rs | UTF-8 | 1,334 | 3.78125 | 4 | [] | no_license | ///
/// Utility functions to check whether a number is a power of two or not
///
pub fn is_pot(num: usize) -> bool {
match num {
0 => false,
n => (n & (n - 1)) == 0
}
}
///
/// Utility function for checking whether a pointer is aligned to an
/// specified alignment or not.
///
pub fn is_aligne... | true |
3d61f90cc11dd62349f5ae820762c1efb7329867 | Rust | adwhit/advent-of-code-2017 | /src/bin/09_stream_processing.rs | UTF-8 | 3,458 | 2.890625 | 3 | [] | no_license | extern crate advent_of_code;
#[macro_use]
extern crate failure;
extern crate itertools;
use advent_of_code::Result;
use std::fs;
use std::io::prelude::*;
fn get_data(path: &str) -> Result<Vec<u8>> {
let mut f = fs::File::open(path)?;
let mut v = Vec::new();
f.read_to_end(&mut v)?;
Ok(v)
}
#[derive(C... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.